Hi,
Having bought a book a while back I have finally started to read it and type in it's listings. Things have been going great until now.
I have come unstuck due to the following error message:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/sspp11aatt/public_html/handle_form.php on line 20
I simply can't figure out what is wrong (the book appears to offer no help here)
Here is the complete code:
1.<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3.<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4.<head>
5. <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
6. <title>Form Feedback</title>
7.</head>
8.<body>
9.<?php # Script 2.5 - handle_form.php (4th version after scripts 2.2, 2.3, & 2.4)
10.
11.// Validate the name and combat Magic Quotes, if necessary.
12.if (!empty($REQUEST['name'])) {
13. $name = stripslashes($REQUEST['name']);
14.} else {
15. $name = NULL;
16. echo '<p><font color="red">You forgot to enter your name!.</font></P>;
17.}
18.
19.// Validate the email.
20.if (!empty($REQUEST['name'])) {
21. $email = $REQUEST['email'];
22.} else {
23. $email = NULL;
24. echo '<p><font color="red">You forgot to enter your email address!</font><p/P';
25.}
26.
27.// Validate the comments and combat Magic Quotes, if necessary.
28.if (!empty($REQUEST['comments'])) {
29. $comments = stripslashes($REQUEST['comments']);
30.} else {
31. $comments = NULL;
32. echo '<p><font color="red">You forgot to enter your comments!</font><p>';
33.}
34.
35.// Validate gender.
36.if (isset($REQUEST['gender'])) {
37.
38. $gender = $REQUEST['gender'];
39.
40. if ($gender == 'M') {
41. $message = '<p><b>Good day, Sir!</b></p>';
42. } elseif ($gender == 'F') {
43. $message = '<p><b>Good day, Madam!</b></p>';
44. } else { // Unacceptable value.
45. $message = NULL;
46. echo '<p><font color="red">Gender should be either "M" or "F"!</font></p>';
47. }
48.
49.} else {
50. $gender = NULL;
51. echo '<p><font color="red">You forgot to select your gender!</font></p>';
52.}
53.
54.// If everything is okay, print the message.
55.if ($name && $email && $gender && $comments) {
56.
57. echo "<p>Thank you, <b>$name</b>, for the following comments:<br />
58. <tt>$comments</tt></p>
59. <p>We will reply to you at <i>$email</i>.</p>\n";
60. echo $message; // From the $gender conditional.
61.
62.} else { // One form element was not filled out properly.
63. echo '<p><font color="red">Please go back and fill out the form again.</font></p>';
64.}
65.
66.?>
67.</body>
68.</html>
All help is greatly recieved.
Thanks
ssppllaatt