Jump to content
Larry Ullman's Book Forums

The Feedback Form


Recommended Posts

I've been working on building the feedback form as detailed in chapter 3. However, upon submitting the feedback form, the user's name does not appear. For example, in the handle_form.php, it comes up:

 

"Thank you, Ms. , for your comments.

 

You stated that you found this example to be 'excellent' and added:

Great job!"

 

The person's name is missing. I have copied my code below. Can you let me know if I'm overlooking something and why it doesn't include the person's name?

 

--------Here is the 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>Feedback Form</title>

 

</head>

 

<body>

 

<!--Script 3.1 - feedback.html-->

<div><p>Please Complete this form to submit your feedback:</p>

 

<form action="handle_form.php" method="post">

 

 

<p>Name: <select name="title">

<option value="Mr.">Mr.</option>

<option value="Mrs.">Mrs.</option>

<option value="Ms.">Ms.</option>

 

</select> <input type="text" name="email" size="20" /></p>

 

<p>Response: This is...

<input type="radio" name="response" value="excellent" />excellent

 

<input type="radio" name="response" value="okay" />okay

 

<input type="radio" name="response" value="boring" />boring

 

<p>Comments: <textarea name="comments" rows="3" cols="30"></textarea></p>

 

<input type="submit" name="submit" value="Send my feedback" />

 

</form>

</div>

</body>

</html>

 

----------------------Here is the PHP----------------------------

<!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>Your Feedback</title>

 

</head>

 

<body>

 

<?php

 

$title = $_POST['title'];

$name = $_POST['name'];

$response = $_POST['response'];

$comments = $_POST['comments']

 

print"<p>Thank you, $title; $name, for your comments.</p>

<p>You stated that you found this example to be '$response' and added: <br />$comments</p>";

 

?>

</body>

</html>

Link to comment
Share on other sites

Thanks for your reply! Though, I'm still a bit confused. Are you meaning here: "</select> <input type="text" name="email" size="20" /></p>" in my html doc?

 

I changed it to: </select> <input type="text" name="name" size="20" /></p>

 

But it still is not working.

Link to comment
Share on other sites

Thats the only problem I can see with your code - when you fixed it did you just press refresh in the browser? If so then you're just resubmitting the old POST data which will contain $_POST['email'] rather then the new $_POST['name']. Access the page fresh i.e. type the URL in again and hit enter. Then resubmit the details and it should work... unless I'm missing something.

  • Upvote 1
Link to comment
Share on other sites

Ah! Yes, that was it! I feel silly now! Works great! Thanks.

 

Thats the only problem I can see with your code - when you fixed it did you just press refresh in the browser? If so then you're just resubmitting the old POST data which will contain $_POST['email'] rather then the new $_POST['name']. Access the page fresh i.e. type the URL in again and hit enter. Then resubmit the details and it should work... unless I'm missing something.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...