[HELP] Probleme d'envoi de nom via formulaire

Dawink
Invité n'ayant pas de compte PHPfrance

16 janv. 2012, 12:33

Bonjour,

voici mon probleme. Via le code php ci dessous, j'envoi un formulaire de contact. Mon souci, c'est que le mail de la personne n'apparait pas dans mon mail, mais j'ai bien son nom qui est récupéré.

Par contre si j'enlève le "$nom" if ($dontsendemail == 0) {mail($emailaddress,"Subject: $subject",$message,$nom,"From: $email" ); c'est son mail qui est récupéré mais pas son nom ???????


Donc en fait soit l'un soit l'autre, mais pas les deux ! ! ! ! !


Une soluce SVP ???

Merci beaucoup de votre aide.....



<?php 
$dontsendemail = 0;
$possiblespam = FALSE;
$strlenmessage = "";
$email = $_REQUEST['email']; 
$message = $_REQUEST['message']; 
$nom = $_POST['nom'];


	$subject = array(); 
	$subject[1] = "horaires";
		$subject[2] = "reservations";
		$subject[3] = "autres";
		$subjectindex = $_REQUEST['subject'];
	if ($subjectindex == 0 || !isset($_REQUEST['subject'])) die ("You did not choose a subject line. Please hit your browser back button and try again.");
	else $subject = $subject[$subjectindex];
	
	$emailaddress = array(); /* NOTE: Although your email addresses
	are visible here in this code, the person contacting you will never see these email addresses. 
	Your email addresses will remain on your server, and they will not be sent from your server 
	to the person contacting you. They will also remain invisible to spam bots. Your email addresses
	are also never stored on any of our servers. You can choose to delete or not delete this note
	when you publish this page. It will not change the functionality of the contact form. 
	*/
	$emailaddress[1] = "[email protected]";
		$emailaddress[2] = "[email protected]";
		$emailaddress[3] = "[email protected]";
		$contactnameindex = $_REQUEST['emailaddress'];
	if ($contactnameindex == 0 || !isset($_REQUEST['emailaddress'])) die ("You did not choose a recipient. Please hit your browser back button and try again.");
	else $emailaddress = $emailaddress[$contactnameindex];
	
function checkemail($field) {
	// checks proper syntax
	if( !preg_match( "/^([a-zA-Z0-9])+([a-zA-Z0-9._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9._-]+)+$/", $field))
	{
		die("Improper email address detected. Please hit your browser back button and try again."); 
		return 1;
	}
}
/*function spamcheck($field) {
	if(eregi("to:",$field) || eregi("cc:",$field) || eregi("\r",$field) || eregi("\n",$field) || eregi("%0A",$field)){ 
		$possiblespam = TRUE;
	}else $possiblespam = FALSE;
	if ($possiblespam) {
		die("Possible spam attempt detected. If this is not the case, please edit the content of the contact form and try again.");
		return 1;
	}
}*/
function strlencheck($field,$minlength,$whichfieldresponse) {
	if (strlen($field) < $minlength){
		die($whichfieldresponse); 
		return 1;
	}
}

if ($dontsendemail == 0) $dontsendemail = checkemail($email);
/*if ($dontsendemail == 0) $dontsendemail = spamcheck($email);*/
/*if ($dontsendemail == 0) $dontsendemail = spamcheck($subject);*/
if ($dontsendemail == 0) $dontsendemail = strlencheck($email,10,"The email address field is too short. Please hit your browser back button and check your entry.<br />");

if ($dontsendemail == 0) $dontsendemail = strlencheck($subject,1,"You did not choose a subject. Please hit your browser back button and check your entry.<br />");
if ($dontsendemail == 0) $dontsendemail = strlencheck($nom,8,"The message field is too short. Please hit your browser back button and check your entry.<br />");
if ($dontsendemail == 0) $dontsendemail = strlencheck($message,10,"The message field is too short. Please hit your browser back button and check your entry.<br />");
if ($dontsendemail == 0) $dontsendemail = strlencheck($emailaddress,8,"You have not selected a recipient of your message. Please hit your browser back button and check your entry.<br />");
if ($dontsendemail == 0) {mail($emailaddress,"Subject: $subject",$message,$nom,"From: $email" );
}
?>




<?
echo '<script language="Javascript">
<!--
document.location.replace("");
// -->
</script>';
?>

ViPHP
ViPHP | 2577 Messages

16 janv. 2012, 12:44

La fonction mail comporte bien 5 parametres, mais le 5ème correspond à des paramètres pour le serveur mail.

Regardes la doc : http://php.net/manual/fr/function.mail.php

Il faudrait remplacé les paramètres 4 et 5 par un truc genre : "From: $nom <$email>"

Dawink
Invité n'ayant pas de compte PHPfrance

16 janv. 2012, 12:55

Merci beaucoup, ce n'est pas tt a fait la reponse que j'attendais mais grace a toi en bidouillant j'ai réussi a le faire fonctionner ! ! ! ! !


Merci encore..............^^

Dawink
Invité n'ayant pas de compte PHPfrance

16 janv. 2012, 12:59

[RESOLU]