Hi!
I've got a page for members to register and/or login to, and a programme to access my mysql db, but whenever I click the submit button on the form page I keep getting:
"Parse error: parse error, unexpected $end in C:\Apache2\webs\Login200703.php on line 158
As I understand it, parse errors are equivalent to php going "Huh?? wtf is that??! lol" but I just can't see what's wrong with that line (?> !!!!!). It must be something that I've written previously, but what, I don't know!
Large though they are, I'll put the files below - "login_form" is the form page and "login200703" is the program. "dogs" is just my mysql username & password file.
Thanks
luds
*********"Login_form"********
<html>
<?php
/* File: login_form.inc
* Desc: Displays login page. Page displays two forms--one form for
* entering an existing login name and password and another
* form for the information needed to apply for a new account.
*/ // 7
?>
<head>
<title>Members Only Login</title>
</head>
<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
<table border="0" cellpadding="5" cellspacing="0">
<tr><td colspan="3" bgcolor="gray" align="center">
<font color="white" size="+10">
<b>Members Only Section</b></font></td></tr>
<tr>
<td width="33%" valign="top">
<font size="+1"><b>Are you a member?</b></font>
<p>
<!-- form for customer login -->
<form action="Login200703.php?do=login" method="post">
<input type="hidden" name="do" value="new">
<table border="0">
<?php // 23
if (isset($message))
echo "<tr><td colspan='2'>$message </td></tr>";
?>
<tr><td align=right><b>Username</b></td>
<td><input type="text" name="fusername" size="20" maxsize="20">
</td></tr>
<tr><td width="120" align="right"><b>Password</b></td>
<td><input type="password" name="fpassword"
size="20" maxsize="20"></td></tr>
<tr><td align="center" colspan="2">
<br><input type="submit" name="log" value="Enter"></td></tr>
</table>
</form>
</td>
<td width="1" bgcolor="gray"></td>
<td width="67%">
<p><font size="+1"><b>Not a member yet?</b></font> Get up to date information,
advance notice of forthcoming events and much more. Fill in the information
below and join. It's easy and free! </b>
<!-- form for new member to fill in -->
<form action="Login200703.php?do=new" method="post">
<input type="hidden" name="do" value="new">
<p>
<table border="0" width="100%">
<?php
if (isset($message_new)) // 48
echo "<tr><td colspan='2'><b>$message_new</b></td></tr>";
?>
<tr>
<td align="right"><b>Member ID</b></td>
<td><input type="text" name="newname"
value="<?php echo $newname ?>"
size="20" maxlength="20"></td>
</tr>
<tr>
<td align="right"><b>Password</b></td>
<td><input type="password" name="newpass"
value="<?php echo $newpass ?>"
size="10" maxlength="8"></td>
</tr>
<tr>
<td align="right"><b>First Name</b></td>
<td><input type="text" name="firstname"
value="<?php echo $firstname ?>"
size="40" maxlength="40"></td>
</tr>
<tr>
<td align="right"><b>Last Name</b></td>
<td><input type="text" name="lastname"
value="<?php echo $lastname ?>"
size="40" maxlength="40"></td>
</tr>
<tr>
<td align="right"><strong>Age Group</strong></td>
<td><p>
<label> </label>
<label>
<input type="radio" name="memberage" value="under 10">
under 10</label>
<br>
<label>
<input type="radio" name="memberage" value="10-18">
10-18</label>
<br>
<label>
<input type="radio" name="memberage" value="19-34">
19-34</label>
<br>
<label>
<input type="radio" name="memberage" value="35-49">
35-49</label>
<br>
<label>
<input type="radio" name="memberage" value="50-64">
50-64</label>
<br>
<label>
<input type="radio" name="memberage" value="over 65">
over 65</label>
<br>
<br>
</p></td>
<td> </td>
</tr>
<tr>
<td align="right"><strong>What best describes you</strong> </td>
<td><p>
<label>
<input type="radio" name="membercatagory" value="Professional Singer">
Professional Singer</label>
<br>
<label>
<input type="radio" name="membercatagory" value="Singing Teacher">
Singing Teacher</label>
<br>
<label>
<input type="radio" name="membercatagory" value="Competition Supporter">
Competition Supporter</label>
<br>
</p></td>
<td> </td>
</tr>
<tr>
<td align="right"><strong>Nationality</strong></td>
<td><select name="membercountry" size="1">
<option>
<option>AFGHANISTAN
<option>ALBANIA
<option>ALGERIA
<option>ARGENTINA
<option>ARMENIA
<option>AUSTRALIA
<option>AUSTRIA
<option>BELARUS
<option>BOSNIA AND HERZEGOWINA
<option>BOTSWANA
<option>BRAZIL
<option>BULGARIA
<option>CANADA
<option>CHILE
<option>CHINA
<option>COLOMBIA
<option>CROATIA (local name: Hrvatska)
<option>CUBA
<option>CZECH REPUBLIC
<option>DENMARK
<option>ECUADOR
<option>EGYPT
<option>EL SALVADOR
<option>ESTONIA
<option>FINLAND
<option>FRANCE
<option>GEORGIA
<option>GERMANY
<option>GIBRALTAR
<option>GREECE
<option>HONG KONG
<option>HUNGARY
<option>ICELAND
<option>IRAQ
<option>IRELAND
<option>ISRAEL
<option>ITALY
<option>JAPAN
<option>KENYA
<option>LEBANON
<option>LITHUANIA
<option>LUXEMBOURG
<option>NETHERLANDS
<option>NEW ZEALAND
<option>NORWAY
<option>Not Available
<option>PARAGUAY
<option>PERU
<option>POLAND
<option>PORTUGAL
<option>ROMANIA
<option>RUSSIAN FEDERATION
<option>SAMOA
<option>SINGAPORE
<option>SLOVAKIA (Slovak Republic)
<option>SLOVENIA
<option>SOUTH AFRICA
<option>SPAIN
<option>SRI LANKA
<option>SUDAN
<option>SWEDEN
<option>SWITZERLAND
<option>TAIWAN, PROVINCE OF CHINA
<option>TAJIKISTAN
<option>TANZANIA, UNITED REPUBLIC OF
<option>THAILAND
<option>TURKEY
<option>UKRAINE
<option selected>UNITED KINGDOM
<option>UNITED STATES
<option>UNKNOWN LOCATION
<option>URUGUAY
<option>UZBEKISTAN
<option>VENEZUELA
</select></td>
<td> </td>
</tr>
<tr>
<td align=right><b>Email Address</b></td>
<td><input type="test" name="email" value="<?php echo $email ?>"
size="55" maxlength="67"></td>
</tr>
<tr>
<td> </td>
<td align="center"> <input type="submit" value="Become a Member"></td>
</tr>
</table>
</form>
</td>
</tr>
<tr><td colspan="3" bgcolor="gray"> </td></tr>
</table>
<div align="center"><font size="-1"> All comments and suggestions are appreciated.
Please send comments to <a href="mailto:webmaster@nationalmozart.com">webmaster@nationalmozart.com</A>
</font></div>
</body>
********"Login"********
<?php
/* Program: Login.php
Desc: Login program for the Members Only section of the
pet store. It provides two options: (1) login using an
existing Login Name and (2) enter a new login name. Login
Names and passwords are stored in a MySQL database.
*/
session_start(); // 8
session_register('auth'); // 9
session_register('logname');
include("C:/Apache2/webs/dogs.inc"
; // 11
switch (@$do) // 12
{
case "login": // 14
$connection = mysql_connect($host, $user,$password) // 15
or die ("Couldn't connect to server."
;
$db = mysql_select_db($database, $connection)
or die ("Couldn't select database."
;
$sql = "SELECT firstname FROM nmc_site_members // 19
WHERE firstname='$fusername'";
$result = mysql_query($sql)
or die("Couldn't execute query."
;
$num = mysql_num_rows($result); // 23
if ($num == 1) // login name was found 24
{
$sql = "SELECT firstname FROM nmc_site_members // 26
WHERE firstname='$fusername'
AND password=password('$fpassword')";
$result2 = mysql_query($sql)
or die("Couldn't execute query."
;
$num2 = mysql_num_rows($result2);
if ($num2 > 0) // password is correct // 32
{
$auth="yes"; // 34
$logname=$fusername; // 35
$today = date("Y-m-d h:m:s"
; // 36
$sql = "INSERT INTO Login (firstname,loginTime)
VALUES ('$logname','$today')";
mysql_query($sql) or die("Can't execute query."
;
header("Location: Member_page.php"
; // 40
}
else // password is not correct // 42
{
unset($do); // 44
$message="The Login Name, '$fusername' exists, // 45
but you have not entered the correct
password! Please try again.br>";
include("login_form"
; // 48
}
} // 50
elseif ($num == 0) // login name not found // 51
{
unset($do); // 53
$message = "The Login Name you entered does not
exist! Please try again.<br>";
include("login_form"
;
}
break; // 58
case "new": // 60
foreach($HTTP_POST_VARS as $key => $value) // 61
{
if ($key != "fax"
// 63
{
if ($value == ""
// 65
{
unset($do);
$message_new = "Required information is missing.
Please try again.";
include("login_form"
;
exit();
}
}
if (ereg("{Name)",$key)) // 74
{
if (!ereg("^[A-Za-z' -]{1,50}$",$key))
{
unset($do);
$message_new = "$firstname is not a valid name.
Please try again.";
include("login_form"
;
exit();
}
if (ereg("{Name)",$key)) // 74
{
if (!ereg("^[A-Za-z' -]{1,50}$",$key))
{
unset($do);
$message_new = "$lastname is not a valid name.
Please try again.";
include("login_form"
;
exit();
}
}
$$key = strip_tags(trim($value)); // 85
}
if (!ereg("^.+@.+\\..+$",$email)) // 114
{
unset($do);
$message_new = "$email is not a valid email address.
Please try again.";
include("login_form"
;
exit();
}
/* check to see if login name already exists */
$connection = mysql_connect($host,$user,$password) // 123
or die ("Couldn't connect to server."
;
$db = mysql_select_db($database, $connection)
or die ("Couldn't select database."
;
$sql = "SELECT firstname FROM nmc_site_members
WHERE firstname='$newname'";
$result = mysql_query($sql)
or die("Couldn't execute query."
;
$num = mysql_numrows($result);
if ($num > 0) // 132
{
unset($do);
$message_new = "$newname already used. Select another
member ID.";
include("login_form"
;
exit();
}
else // 140
{
$today = time("Y-m-d"
;
$sql = "INSERT INTO nmc_site_members (member_ID,createdate,password,
firstname,lastname,membersex,memberage,membercatagory,membercountry,
member_email) VALUES
('$newname','$today',password('$newpass'),
'$firstname', '$lastname','$membersex','$memberage','$membercatagory',
'$membercountry','$member_email')";
mysql_query($sql);
$auth="yes"; // 150
$logname = $newname; // 151
/* send email to new member */ // 152
$emess1="A new Member Account has been setup for you. ";
$emess2="Your new Member ID and password are: ";
$emess3="\n\n\t$newname\n\t$newpass\n\n";
$emess4="We appreciate your interest in The National Mozart Competition ";
$emess5="at nationalmozart.com\n\n";
$emess6="If you have any questions or problems, email ";
$emess7="webmaster@nationalmozart.com";
$emess =
$emess1.$emess2.$emess3.$emess4.$emess5.$emess6.emess7;
$ehead="From: member-desk@petstore.com\r\n"; // 162
$subject = "Your new Member Account from THe National Mozart Competition";
$mailsend=mail("$email","$subject","$emess","$ehead"
;// 164
header("Location: New_member.php"
; // 165
}
}
?>
I've got a page for members to register and/or login to, and a programme to access my mysql db, but whenever I click the submit button on the form page I keep getting:
"Parse error: parse error, unexpected $end in C:\Apache2\webs\Login200703.php on line 158
As I understand it, parse errors are equivalent to php going "Huh?? wtf is that??! lol" but I just can't see what's wrong with that line (?> !!!!!). It must be something that I've written previously, but what, I don't know!
Large though they are, I'll put the files below - "login_form" is the form page and "login200703" is the program. "dogs" is just my mysql username & password file.
Thanks
luds
*********"Login_form"********
<html>
<?php
/* File: login_form.inc
* Desc: Displays login page. Page displays two forms--one form for
* entering an existing login name and password and another
* form for the information needed to apply for a new account.
*/ // 7
?>
<head>
<title>Members Only Login</title>
</head>
<body topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">
<table border="0" cellpadding="5" cellspacing="0">
<tr><td colspan="3" bgcolor="gray" align="center">
<font color="white" size="+10">
<b>Members Only Section</b></font></td></tr>
<tr>
<td width="33%" valign="top">
<font size="+1"><b>Are you a member?</b></font>
<p>
<!-- form for customer login -->
<form action="Login200703.php?do=login" method="post">
<input type="hidden" name="do" value="new">
<table border="0">
<?php // 23
if (isset($message))
echo "<tr><td colspan='2'>$message </td></tr>";
?>
<tr><td align=right><b>Username</b></td>
<td><input type="text" name="fusername" size="20" maxsize="20">
</td></tr>
<tr><td width="120" align="right"><b>Password</b></td>
<td><input type="password" name="fpassword"
size="20" maxsize="20"></td></tr>
<tr><td align="center" colspan="2">
<br><input type="submit" name="log" value="Enter"></td></tr>
</table>
</form>
</td>
<td width="1" bgcolor="gray"></td>
<td width="67%">
<p><font size="+1"><b>Not a member yet?</b></font> Get up to date information,
advance notice of forthcoming events and much more. Fill in the information
below and join. It's easy and free! </b>
<!-- form for new member to fill in -->
<form action="Login200703.php?do=new" method="post">
<input type="hidden" name="do" value="new">
<p>
<table border="0" width="100%">
<?php
if (isset($message_new)) // 48
echo "<tr><td colspan='2'><b>$message_new</b></td></tr>";
?>
<tr>
<td align="right"><b>Member ID</b></td>
<td><input type="text" name="newname"
value="<?php echo $newname ?>"
size="20" maxlength="20"></td>
</tr>
<tr>
<td align="right"><b>Password</b></td>
<td><input type="password" name="newpass"
value="<?php echo $newpass ?>"
size="10" maxlength="8"></td>
</tr>
<tr>
<td align="right"><b>First Name</b></td>
<td><input type="text" name="firstname"
value="<?php echo $firstname ?>"
size="40" maxlength="40"></td>
</tr>
<tr>
<td align="right"><b>Last Name</b></td>
<td><input type="text" name="lastname"
value="<?php echo $lastname ?>"
size="40" maxlength="40"></td>
</tr>
<tr>
<td align="right"><strong>Age Group</strong></td>
<td><p>
<label> </label>
<label>
<input type="radio" name="memberage" value="under 10">
under 10</label>
<br>
<label>
<input type="radio" name="memberage" value="10-18">
10-18</label>
<br>
<label>
<input type="radio" name="memberage" value="19-34">
19-34</label>
<br>
<label>
<input type="radio" name="memberage" value="35-49">
35-49</label>
<br>
<label>
<input type="radio" name="memberage" value="50-64">
50-64</label>
<br>
<label>
<input type="radio" name="memberage" value="over 65">
over 65</label>
<br>
<br>
</p></td>
<td> </td>
</tr>
<tr>
<td align="right"><strong>What best describes you</strong> </td>
<td><p>
<label>
<input type="radio" name="membercatagory" value="Professional Singer">
Professional Singer</label>
<br>
<label>
<input type="radio" name="membercatagory" value="Singing Teacher">
Singing Teacher</label>
<br>
<label>
<input type="radio" name="membercatagory" value="Competition Supporter">
Competition Supporter</label>
<br>
</p></td>
<td> </td>
</tr>
<tr>
<td align="right"><strong>Nationality</strong></td>
<td><select name="membercountry" size="1">
<option>
<option>AFGHANISTAN
<option>ALBANIA
<option>ALGERIA
<option>ARGENTINA
<option>ARMENIA
<option>AUSTRALIA
<option>AUSTRIA
<option>BELARUS
<option>BOSNIA AND HERZEGOWINA
<option>BOTSWANA
<option>BRAZIL
<option>BULGARIA
<option>CANADA
<option>CHILE
<option>CHINA
<option>COLOMBIA
<option>CROATIA (local name: Hrvatska)
<option>CUBA
<option>CZECH REPUBLIC
<option>DENMARK
<option>ECUADOR
<option>EGYPT
<option>EL SALVADOR
<option>ESTONIA
<option>FINLAND
<option>FRANCE
<option>GEORGIA
<option>GERMANY
<option>GIBRALTAR
<option>GREECE
<option>HONG KONG
<option>HUNGARY
<option>ICELAND
<option>IRAQ
<option>IRELAND
<option>ISRAEL
<option>ITALY
<option>JAPAN
<option>KENYA
<option>LEBANON
<option>LITHUANIA
<option>LUXEMBOURG
<option>NETHERLANDS
<option>NEW ZEALAND
<option>NORWAY
<option>Not Available
<option>PARAGUAY
<option>PERU
<option>POLAND
<option>PORTUGAL
<option>ROMANIA
<option>RUSSIAN FEDERATION
<option>SAMOA
<option>SINGAPORE
<option>SLOVAKIA (Slovak Republic)
<option>SLOVENIA
<option>SOUTH AFRICA
<option>SPAIN
<option>SRI LANKA
<option>SUDAN
<option>SWEDEN
<option>SWITZERLAND
<option>TAIWAN, PROVINCE OF CHINA
<option>TAJIKISTAN
<option>TANZANIA, UNITED REPUBLIC OF
<option>THAILAND
<option>TURKEY
<option>UKRAINE
<option selected>UNITED KINGDOM
<option>UNITED STATES
<option>UNKNOWN LOCATION
<option>URUGUAY
<option>UZBEKISTAN
<option>VENEZUELA
</select></td>
<td> </td>
</tr>
<tr>
<td align=right><b>Email Address</b></td>
<td><input type="test" name="email" value="<?php echo $email ?>"
size="55" maxlength="67"></td>
</tr>
<tr>
<td> </td>
<td align="center"> <input type="submit" value="Become a Member"></td>
</tr>
</table>
</form>
</td>
</tr>
<tr><td colspan="3" bgcolor="gray"> </td></tr>
</table>
<div align="center"><font size="-1"> All comments and suggestions are appreciated.
Please send comments to <a href="mailto:webmaster@nationalmozart.com">webmaster@nationalmozart.com</A>
</font></div>
</body>
********"Login"********
<?php
/* Program: Login.php
Desc: Login program for the Members Only section of the
pet store. It provides two options: (1) login using an
existing Login Name and (2) enter a new login name. Login
Names and passwords are stored in a MySQL database.
*/
session_start(); // 8
session_register('auth'); // 9
session_register('logname');
include("C:/Apache2/webs/dogs.inc"
switch (@$do) // 12
{
case "login": // 14
$connection = mysql_connect($host, $user,$password) // 15
or die ("Couldn't connect to server."
$db = mysql_select_db($database, $connection)
or die ("Couldn't select database."
$sql = "SELECT firstname FROM nmc_site_members // 19
WHERE firstname='$fusername'";
$result = mysql_query($sql)
or die("Couldn't execute query."
$num = mysql_num_rows($result); // 23
if ($num == 1) // login name was found 24
{
$sql = "SELECT firstname FROM nmc_site_members // 26
WHERE firstname='$fusername'
AND password=password('$fpassword')";
$result2 = mysql_query($sql)
or die("Couldn't execute query."
$num2 = mysql_num_rows($result2);
if ($num2 > 0) // password is correct // 32
{
$auth="yes"; // 34
$logname=$fusername; // 35
$today = date("Y-m-d h:m:s"
$sql = "INSERT INTO Login (firstname,loginTime)
VALUES ('$logname','$today')";
mysql_query($sql) or die("Can't execute query."
header("Location: Member_page.php"
}
else // password is not correct // 42
{
unset($do); // 44
$message="The Login Name, '$fusername' exists, // 45
but you have not entered the correct
password! Please try again.br>";
include("login_form"
}
} // 50
elseif ($num == 0) // login name not found // 51
{
unset($do); // 53
$message = "The Login Name you entered does not
exist! Please try again.<br>";
include("login_form"
}
break; // 58
case "new": // 60
foreach($HTTP_POST_VARS as $key => $value) // 61
{
if ($key != "fax"
{
if ($value == ""
{
unset($do);
$message_new = "Required information is missing.
Please try again.";
include("login_form"
exit();
}
}
if (ereg("{Name)",$key)) // 74
{
if (!ereg("^[A-Za-z' -]{1,50}$",$key))
{
unset($do);
$message_new = "$firstname is not a valid name.
Please try again.";
include("login_form"
exit();
}
if (ereg("{Name)",$key)) // 74
{
if (!ereg("^[A-Za-z' -]{1,50}$",$key))
{
unset($do);
$message_new = "$lastname is not a valid name.
Please try again.";
include("login_form"
exit();
}
}
$$key = strip_tags(trim($value)); // 85
}
if (!ereg("^.+@.+\\..+$",$email)) // 114
{
unset($do);
$message_new = "$email is not a valid email address.
Please try again.";
include("login_form"
exit();
}
/* check to see if login name already exists */
$connection = mysql_connect($host,$user,$password) // 123
or die ("Couldn't connect to server."
$db = mysql_select_db($database, $connection)
or die ("Couldn't select database."
$sql = "SELECT firstname FROM nmc_site_members
WHERE firstname='$newname'";
$result = mysql_query($sql)
or die("Couldn't execute query."
$num = mysql_numrows($result);
if ($num > 0) // 132
{
unset($do);
$message_new = "$newname already used. Select another
member ID.";
include("login_form"
exit();
}
else // 140
{
$today = time("Y-m-d"
$sql = "INSERT INTO nmc_site_members (member_ID,createdate,password,
firstname,lastname,membersex,memberage,membercatagory,membercountry,
member_email) VALUES
('$newname','$today',password('$newpass'),
'$firstname', '$lastname','$membersex','$memberage','$membercatagory',
'$membercountry','$member_email')";
mysql_query($sql);
$auth="yes"; // 150
$logname = $newname; // 151
/* send email to new member */ // 152
$emess1="A new Member Account has been setup for you. ";
$emess2="Your new Member ID and password are: ";
$emess3="\n\n\t$newname\n\t$newpass\n\n";
$emess4="We appreciate your interest in The National Mozart Competition ";
$emess5="at nationalmozart.com\n\n";
$emess6="If you have any questions or problems, email ";
$emess7="webmaster@nationalmozart.com";
$emess =
$emess1.$emess2.$emess3.$emess4.$emess5.$emess6.emess7;
$ehead="From: member-desk@petstore.com\r\n"; // 162
$subject = "Your new Member Account from THe National Mozart Competition";
$mailsend=mail("$email","$subject","$emess","$ehead"
header("Location: New_member.php"
}
}
?>