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( "nickb53@tiscali.co.uk", "Contact Request", $message, "From: $email" ); print "Congratulations your email has been sent"; ?> Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 28, 2008 Share Posted May 28, 2008 Where do you want to put $name? Quote Link to comment 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( "nickb53@tiscali.co.uk", "Contact Request", $message, $name, "From: $email" ); this causes the email adress to come trough as server adress, not the sender is my code incorrect? Quote Link to comment 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? Quote Link to comment 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: root@server05.unITYguy.neT and not the email I added, if I remove the $name then I get the correct email? thanks Quote Link to comment 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( "nickb53@tiscali.co.uk", "Contact Request", $message, "From: $email" ); Quote Link to comment 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 ! Quote Link to comment 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 = "nickb53@tiscali.co.uk"; $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 Quote Link to comment Share on other sites More sharing options...
Gighalen Posted May 28, 2008 Share Posted May 28, 2008 $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; mail( "nickb53@tiscali.co.uk", "Contact Request", $message, "From: $email" ); echo "Thank you!"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.