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( "shngarland@gmail.com", "Feedback Form Results", $message, "From: $email" ); header( "Location: http://www.jlcustombikes.com/thanks.php" ); } ?> Quote Link to comment Share on other sites More sharing options...
davidannis Posted July 15, 2014 Share Posted July 15, 2014 (edited) After $message = $_REQUEST['message'] ; add $message .= "\n".$name."\n".$phone ; You should also validate the input beyond just making sure it is not empty. Edited July 15, 2014 by davidannis Quote Link to comment 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; Quote Link to comment 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 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.