Hi all! Well, after a 7 month sabbatical, I'm back to trying to learn PHP.
Unfortunately, one of my first real PHP programs won't even run?!
What a horrible way to get started.
I'm using Larry Ullman's "PHP for the World Wide Web, 2nd Edition". He has a simple form that you fill out (i.e. "feedback.html") which is then supposed to launch a simple screen (i.e. "handle_form.php") printing what was entered.
When I click on the "Send My Feedback" button, I get this...
"; ?>
Here are my two files...
feedback.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=UTF-8">
<title>Feedback Form</title>
</head>
<body>
Please complete this form to sumbit your feedback: <br />
<!-- Added Form Attribute: method="post" -->
<form action="handle_form.php" method="post">
Mr. <input type="radio" name="title" value="Mr." />
Mrs. <input type="radio" name="title" value="Mrs." />
Ms. <input type="radio" name="title" value="Ms.">
<br />
Name: <input type="text" name="name" size="20" />
<br />
Email Address: <input type="text" name="email" size="20" />
<br />
Response: <select name="response">
<option value="excellent">This is excellent.</option>
<option value="okay">This is okay.</option>
<option value="boring">This is boring.</option>
</select>
<br />
Comments: <textarea name="comments" rows="3" cols="30"></textarea>
<br />
<input type="submit" name="submit" value="Send My Feedback" />
</form>
</body>
</html>
handle_form.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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Your Feedback</title>
</head>
<body>
<?php
// This page receives data from the Feedback Form
// It will receive: Title, Name, Email, Response, Comments, and Submit
print "Thank you {$_POST['title']} {$_POST['name']} for your comments. <br />";
?>
</body>
</html>
The whole point of this exercise in the book was to show you how to work with Displaying Errors (i.e. 'display_errors=on' ), Error Reporting (e.g. 'error_reporting (E_ALL)' ) and The Register Globals Problem.
I was originally doing this in NetBeans 6.5, but when I couldn't get anything working, I dumped each file in my Web Root Directory and just started using TextEdit, but to no avail?!
I also played around substantially with my php.ini file, and I honestly could see where turning register_globals from "Off" to "On" solved anything?!
He was showing how something like:
print "Thank you $title $name for your comments. <br />";
worked when register_globals=On, but how you needed:
print "Thank you {$_POST['title']} {$_POST['name']} for your comments. <br />";
when register_globals = Off
I am soooo frustrated right now. I can't believe something so simple is so difficult for me to undestand and get working?!
Any help would be appreciated!
Sincerely,
Amy