shane_77 Posted July 15, 2014 Share Posted July 15, 2014 I'm trying to code my first php contact form from a tutorial I found and I have it working fine except Im not receiving the information from all the fields. Im having trouble adding the fields at the end of the code. Could somebody please help me out and tell me how to add the name and phone fields into the script. Many Thanks Shane. < ?php $name = $_REQUEST['name'] ; $email = $_REQUEST['email'] ; $phone = $_REQUEST['phone'] ; $message = $_REQUEST['message'] ; if (!isset($_REQUEST['email'])) { header( "Location: http://www.jlcustombikes.com" ); } elseif (empty($name) || empty($email) || empty($phone) || empty($message)) { header( "Expires: Mon, 20 Dec 1998 01:00:00 GMT" ); header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" ); header( "Cache-Control: no-cache, must-revalidate" ); header( "Pragma: no-cache" ); ?> <html> <head><title>Error</title></head> <body> <h1>Error</h1> <p> Oops, it appears you forgot to enter either your email address or your message. Please press the BACK button in your browser and try again. </p> </body> </html> <?php } else { mail( "[email protected]", "Feedback Form Results", $message, "From: $email" ); header( "Location: http://www.jlcustombikes.com/thanks.php" ); } ?> Link to comment https://forums.phpfreaks.com/topic/289898-help-with-email-form/ Share on other sites More sharing options...
davidannis Posted July 15, 2014 Share Posted July 15, 2014 After $message = $_REQUEST['message'] ; add $message .= "\n".$name."\n".$phone ; You should also validate the input beyond just making sure it is not empty. Link to comment https://forums.phpfreaks.com/topic/289898-help-with-email-form/#findComment-1485160 Share on other sites More sharing options...
fastsol Posted July 15, 2014 Share Posted July 15, 2014 Put this just after your $message = $_REQUEST['message']; $message = "Name: ".$name."\nPhone: ".$phone."\nMessage: ".$message; Link to comment https://forums.phpfreaks.com/topic/289898-help-with-email-form/#findComment-1485161 Share on other sites More sharing options...
shane_77 Posted July 15, 2014 Author Share Posted July 15, 2014 Thanks for the help Davidannis and Fastsol I appreciate the help. Ill give that a try. Thank You Link to comment https://forums.phpfreaks.com/topic/289898-help-with-email-form/#findComment-1485377 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.