confused_aswell Posted October 13, 2008 Share Posted October 13, 2008 Hi I have got an odd problem, I have this simple form script where I need it to show some information in the resulting php file. What is happening, the php text is showing up in the php file but the variables are not. Any ideas? I am on a hosting package. Thanks Phil [<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>HTML Form</title> </head> <body> <!-- Script 2.1 - form.html --> <form action="handle_form.php" method="post"> <fieldset><legend>Enter your information in the form below:</legend> <p><b>Name:</b> <input type="text" name="name" size="20" maxlength="40" /></p> <p><b>Email Address:</b> <input type="text" name="email" size="40" maxlength="60" /> </p> <p><b>Gender:</b> <input type="radio" name="gender" value="M" /> Male <input type="radio" name="gender" value="F" /> Female</p> <p><b>Age:</b> <select name="age"> <option value="0-30">Under 30</option> <option value="30-60">Betweeen 30 and 60</option> <option value="60+">Over 60</option> </select> </p> <p><b>Comments:</b> <textarea name="comments" rows="3" cols="50"></textarea></p> </fieldset> <div align="center"><input type="submit" name="submit" value="Submit Information" /></div> </form><!-- End of Form --> </body> </html>/code] this is passed to this script [code]<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <title>Form Feedback</title> </head> <body> <?php # Script 2.2 - handle_form.php echo "Thank you, <b>$name</b> for the following comments:<br /><tt>$comments</tt><p>We will reply to you at <i>$email</i>.</p>"; ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/128186-solved-browser-not-showing-variables/ Share on other sites More sharing options...
trq Posted October 13, 2008 Share Posted October 13, 2008 You haven't defined the variables anywhere. Take a look at the $_POST[] array, ie instead of using $name you need to use $_POST['name']. Quote Link to comment https://forums.phpfreaks.com/topic/128186-solved-browser-not-showing-variables/#findComment-663894 Share on other sites More sharing options...
Lamez Posted October 13, 2008 Share Posted October 13, 2008 change this: <?php echo "Thank you, <b>$name</b> for the following comments:<br /><tt>$comments</tt><p>We will reply to you at <i>$email</i>.</p>"; ?> to this: <?php $name = $_POST['name']; $comments = $_POST['comments']; $email = $_POST['email']; echo "Thank you, <b>".$name."</b> for the following comments:<br /><tt>".$comments."</tt><p>We will reply to you at <i>".$email."</i>.</p>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/128186-solved-browser-not-showing-variables/#findComment-663896 Share on other sites More sharing options...
confused_aswell Posted October 13, 2008 Author Share Posted October 13, 2008 Hi Thanks, it all works now. Cheers, have a nice day! Phil Quote Link to comment https://forums.phpfreaks.com/topic/128186-solved-browser-not-showing-variables/#findComment-663897 Share on other sites More sharing options...
Lamez Posted October 13, 2008 Share Posted October 13, 2008 don't forget to mark the topic as solved. Quote Link to comment https://forums.phpfreaks.com/topic/128186-solved-browser-not-showing-variables/#findComment-663899 Share on other sites More sharing options...
confused_aswell Posted October 13, 2008 Author Share Posted October 13, 2008 How do I do this? Phil Quote Link to comment https://forums.phpfreaks.com/topic/128186-solved-browser-not-showing-variables/#findComment-663901 Share on other sites More sharing options...
Lamez Posted October 13, 2008 Share Posted October 13, 2008 look at the bottom left of the page. Quote Link to comment https://forums.phpfreaks.com/topic/128186-solved-browser-not-showing-variables/#findComment-663903 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.