Warren.Tolentino Posted September 2, 2015 Share Posted September 2, 2015 i see the PHP code after submitting the form this is when i hit the button submit my information thru the form.html. form.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"xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Simple HTML Form</title><style type="text/css" title="text/css" media="all"> label { font-weight: bold; color: #300ACC; }</style> </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><label>Name: <input type="text" name="name" size="20" maxlength="40" /></label></p> <p><label>Email Address: <input type="text" name="email" size="20" maxlenght="60" /></label></p> <p><label for="gender">Gender:</label> <input type="radio" name="gender" value="M" /> Male <input type="radio" name="gender" value="F" /> Female </p> <p><label>Age: <select name="age"> <option value="0-29">under 30</option> <option value="30-60">between 30 and 60</option> <option value="60+">over 60></option> </select> </label> <p><label>comments: <textarea name="comments" rows="3" cols="40"></textarea></lable></p> </fieldset> <p align="center"><input type="submit" name="submit" value="submit my information" /></p></form> </body></html> handle_form.php: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhmtl1/DTD/xhmtl1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhmtl"xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Form Feedback</title> </head> <body> <?php #script 2.2 handle_form.php //create shorthand for the form data: $name = $_REQUEST['name']; $email = $_REQUEST['email']; $comments = $_REQUEST['comments']; //print the submitted information: echo "<p>Thank you, <b>$name</b>, for the following comments:<br /> <tt>$comments</tt></p> <p>We will reply to you at <i>$email</i>.</p>\n"; ?> </body></html> please help. thanks. warren Link to comment Share on other sites More sharing options...
Larry Posted September 2, 2015 Share Posted September 2, 2015 By far the most common cause if this is you're not loading the form page through a URL. Your browser should load it through http://, not file:// Link to comment Share on other sites More sharing options...
Warren.Tolentino Posted September 3, 2015 Author Share Posted September 3, 2015 (edited) i tried this http://c/xampp/htdocs/LabTest/form.html it does not work i get host not found. i tried this file:///C:/xampp/htdocs/LabTest/form.html that works but looks like it is not recognizing the values pass to parameters. Thank you, $name, for the following comments:$comments We will reply to you at $email.\n"; ?> please advise thanks. Edited September 3, 2015 by warrentolentino Link to comment Share on other sites More sharing options...
Warren.Tolentino Posted September 3, 2015 Author Share Posted September 3, 2015 i think i solved it going back thru chapter 1 i need to use the http://localhost/...and that works Link to comment Share on other sites More sharing options...
Larry Posted September 5, 2015 Share Posted September 5, 2015 Yep, that'll do it. Glad you've got it working! Link to comment Share on other sites More sharing options...
Recommended Posts