nickb_53 Posted May 28, 2008 Share Posted May 28, 2008 I cant figure this form out, Im New to PHP the form has 3 fields (name, email, and message) I can get the form to work but cant include the name field in the results? Ive tried to add , $name after the $message, But this results in the from email address coming through incorrect? sorry Im new to PHP. any help be gratefull _________________________________________________________________________________________________ <form id="form1" action="sendmail3.php" method="post" enctype="multipart/form-data" name="form1"> Name:<div class="form"> <input name="name" type="text" size="30"> E-Mail:</div> <div class="form"> <input name="email" type="text" value="" size="30"> Message:</div> <textarea name="message" cols="33" rows="11"></textarea> a href="#" class="link" onClick="document.getElementById('form1').reset()">clear</a><a href="#" class="link" onClick="document.getElementById('form1').submit()">send</a><br> </form> ________________________________________________________________________________________________________ the sendmail3.php <? $email = $_POST['email'] ; $message = $_POST['message'] ; $name = $_POST['name'] ; mail( "[email protected]", "Contact Request", $message, "From: $email" ); print "Congratulations your email has been sent"; ?> Link to comment https://forums.phpfreaks.com/topic/107607-simple-form-help/ Share on other sites More sharing options...
DarkWater Posted May 28, 2008 Share Posted May 28, 2008 Where do you want to put $name? Link to comment https://forums.phpfreaks.com/topic/107607-simple-form-help/#findComment-551523 Share on other sites More sharing options...
nickb_53 Posted May 28, 2008 Author Share Posted May 28, 2008 either before or after the Message Ive tried mail( "[email protected]", "Contact Request", $message, $name, "From: $email" ); this causes the email adress to come trough as server adress, not the sender is my code incorrect? Link to comment https://forums.phpfreaks.com/topic/107607-simple-form-help/#findComment-551524 Share on other sites More sharing options...
ILYAS415 Posted May 28, 2008 Share Posted May 28, 2008 which one comes out incorrectly? the $email one or the nickb53 one? Link to comment https://forums.phpfreaks.com/topic/107607-simple-form-help/#findComment-551537 Share on other sites More sharing options...
nickb_53 Posted May 28, 2008 Author Share Posted May 28, 2008 the name and message are correct in the recieved email but the email adress comes though AS From: [email protected] and not the email I added, if I remove the $name then I get the correct email? thanks Link to comment https://forums.phpfreaks.com/topic/107607-simple-form-help/#findComment-551543 Share on other sites More sharing options...
BlueSkyIS Posted May 28, 2008 Share Posted May 28, 2008 because mail() only takes 4 parameters. name is not one of them. mail( "[email protected]", "Contact Request", $message, "From: $email" ); Link to comment https://forums.phpfreaks.com/topic/107607-simple-form-help/#findComment-551570 Share on other sites More sharing options...
nickb_53 Posted May 28, 2008 Author Share Posted May 28, 2008 how can I include the name? so In the email I get a name, and message, and the correct email addresss ! Link to comment https://forums.phpfreaks.com/topic/107607-simple-form-help/#findComment-551751 Share on other sites More sharing options...
ILYAS415 Posted May 28, 2008 Share Posted May 28, 2008 try replacing your sendmail2.php with... <?php $to = "[email protected]"; $subject = "Contact Request"; $message = $_POST['message']; $email= $_POST['email']; $headers = 'From: $email' . "\r\n"; //<-- not sure if this one is completely right mail($to, $subject, $message, $headers); ?> hopefully that'll fix ur problem Link to comment https://forums.phpfreaks.com/topic/107607-simple-form-help/#findComment-551784 Share on other sites More sharing options...
Gighalen Posted May 28, 2008 Share Posted May 28, 2008 $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; mail( "[email protected]", "Contact Request", $message, "From: $email" ); echo "Thank you!"; Link to comment https://forums.phpfreaks.com/topic/107607-simple-form-help/#findComment-551794 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.