danm8 Posted June 21, 2010 Share Posted June 21, 2010 Gday, im trying to code a contact form for my website. When I run this code, it doesnt seem to get information from my form. For example it doenst print out the name out in the confirmation page. Help? Any help would be fantastic contact.html <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”> <html xmlns=”http://www.w3.org/1999/xhtml”> <head> <meta http-equiv=”content-type” content=”text/html; charset=iso-8859-1? /> <title>Contact Us</title> </head> <body> <form action="contactForm.php" method=”post”> Name: <br /> <input type=”text” name=”name” /> <br /><br /> Email Address: <br /> <input type=”text” name=”email” /> <br /><br /> Comments: <br /> <textarea rows=”10? cols=”20? name=”comments”> </textarea> <br /><br /> <input type="submit" value="send" /> </form> </body> </html> contactForm.php <?php $name = $_POST['name']; $email = $_POST['email']; $comments = $_POST['comments']; $to = “[email protected]“; $subject = “Comments From Website”; $input_name = “Name: $name\n\n”; $input_email = “Email: $email\n\n”; $input_comments = $comments; $message = $input_name.$input_email.$input_comments; mail($to,$subject,$message); ?> <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”> <html xmlns=”http://www.w3.org/1999/xhtml”> <head> <meta http-equiv=”content-type” content=”text/html; charset=iso-8859-1? /> <title>Comments received</title> </head> <body> <h2>Your comments are appreciated.</h2> <p><strong><?php echo($name); ?></strong>, we value your comments. We will see that we promptly reply to you at the following email address: <?php echo($email); ?></p> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/205392-php-basic/ Share on other sites More sharing options...
PFMaBiSmAd Posted June 21, 2010 Share Posted June 21, 2010 Most of the quotes in your HTML markup are smart-quotes/curly-quotes (i.e. ” and “) Your HTML markup should only contain straight quotes " or ' Quote Link to comment https://forums.phpfreaks.com/topic/205392-php-basic/#findComment-1074871 Share on other sites More sharing options...
danm8 Posted June 21, 2010 Author Share Posted June 21, 2010 Most of the quotes in your HTML markup are smart-quotes/curly-quotes (i.e. ” and “) Your HTML markup should only contain straight quotes " or ' yeah i noticed that as well before you posted. And i changed them all, but now it information wont even post (the data wont show up in the addresss bar when i click submit). So now i'm back to square 1. Edit: Here is the code with all the quotes fixed <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Contact Us</title> </head> <body> <form action="contactForm.php" method="post"> Name: <br /> <input type="text" name="name" /> <br /><br /> Email Address: <br /> <input type="text" name="email" /> <br /><br /> Comments: <br /> <textarea rows="10" cols="20" name="comments"> </textarea> <br /><br /> <input type="submit" value="send" /> </form> </body> </html> <?php $name = $_POST['name']; $email = $_POST['email']; $comments = $_POST['comments']; $to = "[email protected]"; $subject = "Comments From Website"; $input_name = "Name: $name\n\n"; $input_email = "Email: $email\n\n"; $input_comments = $comments; $message = $input_name.$input_email.$input_comments; mail($to,$subject,$message); ?> <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”> <?xml version="1.0" encoding="iso-8859-1"?> <html xmlns=”http://www.w3.org/1999/xhtml”> <head> <title>Comments received</title> </head> <body> <h2>Your comments are appreciated.</h2> <p><strong><?php echo($name); ?></strong>, we value your comments. We will see that we promptly reply to you at the following email address: <?php echo($email); ?></p> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/205392-php-basic/#findComment-1074873 Share on other sites More sharing options...
danm8 Posted June 21, 2010 Author Share Posted June 21, 2010 lock thread, i got it working Quote Link to comment https://forums.phpfreaks.com/topic/205392-php-basic/#findComment-1074972 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.