I am creating an RSVP form that is supposed to submit information to sendrsvp.php.
When I click on submit, I am getting the following errors:
Parse error: syntax error, unexpected '[', expecting T_PAAMAYIM_NEKUDOTAYIM in C:\xampp\htdocs\Chapter.06\Projects\SendRSVP.php on line 25
I have checked everything over again to the point where I can't find any errors.
Can someone please proof my code and let me know if you find anything? The error states unexpected '[' but all my '[' are paired up.
Code for rsvp.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>RSVP</title>
<meta http-equiv="content-type"
content="texthtml; charset=iso-8859-1" />
</head>
<body>
<h1>Invitation</h1>
<p>You are cordially invited to attend the celebration of the
Anderson's 50th wedding on October 15 at 8:00 p.m.</p>
<form action="SendRSVP.php" method ="get">
<h2>RSVP</h2>
<p>Name <input type="text" name="name" size="50" /></p>
<p><input type="radio" name="attendance" value="yes" />I will
attend <input type="radio" name="attendance" />I will
NOT attend </p>
<p>Number of guests besides myself <input type="text" name="guests" /></p>
<p><input type="submit" value="Send RSVP" /><input type="reset" /></p></form>
<p><a href="attending.php">See Who's Attending</a><br />
<a href="notattending.php">See Who's Not Attending</a></p>
</body>
</html>
Code for sendrsvp.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>RSVP</title>
<meta http-equiv="content-type"
content="texthtml; charset=iso-8859-1" />
</head>
<body>
<?php
if (empty($_GET['name']) || !isset($_GET['attendance']))
echo "<p>You must enter your name and specify whether you
will attend! Click your browser's Back button to
return to the RSVP form.</p>";
else if ($_GET['attendance'] == "yes"
&& !is_numeric(&_GET['guests']))
echo "<p>Please specify the number of guests who will
accompany you! Click on your browser's Back button to
return to the RSVP form.</p>";
else
{
if ($_GET['attendance'] == "yes")
{
$YesFile = "attending.txt";
if (file_put_contents($YesFile, addslashes($_GET['name'])
. ", " . $_GET['guests'] . "\n", FILE_APPEND))
echo "<p>Thanks for RSVPing! We're looking forward
to seeing you!</p>;
else
echo "<p>Cannot save to the $YesFile file.</p>";
}
if ($_GET['attendance'] == "no")
{
$NoFile = "notattending.txt";
if (file_put_contents($NoFile, addslashes($_GET['name'])
. "\n", FILE_APPEND))
echo "<p>Thanks for RSVPing! Sorry you can't
make it!</p>;
else
echo "<p>Cannot save to the $NoFile file.</p>";
}
}
?>
</body>
</html>
I am new at php so your assistance would be greatly appreciated!