herghost Posted August 2, 2008 Share Posted August 2, 2008 I have this as my php code for sending a form: <html> <body> <?php $to = "*******@gmail.com"; $subject = "Contact Form"; $name = $HTTP_POST_VARS['name']; $emailadd =$HTTP_POST_VARS['emailadd']; $message = $HTTP_POST_VARS['message']; $checkbox=$_POST['checkbox']; if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $emailadd)) { echo "<h4>Invalid email address</h4>"; echo "<a href='javascript:history.back(1);'>back</a>"; } elseif ($name == "") { echo "<h4>Please enter your name</h4>"; echo "<a href='javascript:history.back(1);'>back</a>"; } elseif ($message == "") { echo "<h4>Please enter a message</h4>"; echo "<a href='javascript:history.back(1);'>back</a>"; } elseif (mail($to,$subject,$emailadd,$name,$message)) { echo "<h4>Thank you for sending us a message, we shall get back to you shortly<br><br>www.tiny-pixel.co.uk</h4>"; } else { echo "<h4>Can't send email to $email</h4>"; } //checkbox code ?> </body> </html> However when I receive the email I only get the results of the $emailadd and $name result boxes not the $message? Just cant work it out! If i swap the variables around I can get the message but not one of the others, so I assume it will send the email to the variable in the 1st field and 2 other variables, but not all 3! What am i missing? Link to comment https://forums.phpfreaks.com/topic/117855-solved-probably-very-simple-forms/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 2, 2008 Share Posted August 2, 2008 The definition of the mail() function - Description bool mail ( string $to, string $subject, string $message [, string $additional_headers [, string $additional_parameters]] ) The 3rd parameter becomes the message body of the email. Link to comment https://forums.phpfreaks.com/topic/117855-solved-probably-very-simple-forms/#findComment-606195 Share on other sites More sharing options...
herghost Posted August 2, 2008 Author Share Posted August 2, 2008 ah thankyou so could I put the message as an $additional_headers? or combine to variables into one string? Thnaks Dave Link to comment https://forums.phpfreaks.com/topic/117855-solved-probably-very-simple-forms/#findComment-606196 Share on other sites More sharing options...
herghost Posted August 2, 2008 Author Share Posted August 2, 2008 I have combined to $ after the validation check and now all works Thanks for the heads up Link to comment https://forums.phpfreaks.com/topic/117855-solved-probably-very-simple-forms/#findComment-606201 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.