A
Anonymous
Guest
How come i get this error
Parse error: parse error in /data/hosted/oni105/Login.php on line 20
when my form looks like this
<?php
/* Program: Login.php
Desc: Login program for the Members Only section of the
wesite. 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();
session_register('auth');
session_register('username');
include("dogs.inc");
switch (@$do)
{
case "login":
$connection = mysql_connect($host, $user,$password)
or die ("Couldn't connect to server.");
$db = mysql_select_db($database, $connection)
or die (Couldn't select database.");
$sql = "SELECT loginName FROM members
WHERE loginName='$fusername'"
$result = mysql_query($sql)
or die("Couldn't execute query.");
$num = mysql_num_rows($result);
if ($num ==1) // login name was found
{
$sql = "SELECT loginName From members
WHERE loginName='$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
{
$auth="yes";
$logname=$fusername;
$today = date("Y-m-d h:m:s");
$sql = "INSERT INTO Login (loginName, loginTime)
VALUES ('$logname','$today')";
mysql_query($sql) or die(Can't execute query.");
header("Location: Member_page.php");
}
else // password is not correct
{
unset($do);
$message="The Login Name, '$fusername' exists,
but you have not entered the correct
password! Please try again.<br>";
include("login_form.inc");
}
}
elseif ($num == 0) // login name not found
{
unset($do);
$message = "The Login Name you entered does not
exist! Please try again.<br>";
include("login_form.inc");
}
break;
case "new":
foreach($HTTP_POST_VARS as $key => $value)
}
if (!ereg("^.+@.+\\..+$",$email))
{
unset($do);
$message_new = "$email is not a valid email address.
Please try again.";
include("login_form.inc");
exit();
}
/* check to see if login name already exists */
$connection = mysql_connect($host,$user,$password)
or die ("Couldn't connect to server.");
$db = mysql_select_db($database, $connection)
or die (Couldn't select database.");
$sql = "SELECT loginName FROM members
WHERE loginName='$newname'";
$result = mysql_query($sql)
or die("Couldn't execute query.");
$num = mysql_numrows($result);
if ($num > 0)
{
unset($do);
$message_new = "$newname already used. Select another
loginName.";
include("login_form.inc");
exit();
}
else
{
$today = time("Y-m-d");
$sql = "INSERT INTO members (loginName,password,firstName,
email) VALUES
('$newname','$today',password('$newpass'),
'$firstName','$email')";
mysql_query($sql);
$auth="yes";
$logname = $newname;
/* send email to new member */
$emess1=" A new member account has been setup for you. ";
$emess2="Your new loginName and password are: ";
$emess3="\n\n\t$loginName\n\t$newpass\n\n";
$emess4="I appreciate your interest in my game ";
$emess5="at http://www.hostultra.com/~oni105";
$emess6="If you have any questions or problems, email ";
$emess7="adumbleton2003@lycos.co.uk";
$emess =
$emess1.$emess2.$emess3.$emess4.$emess5.$emess6.$emess7:
$ehead="From: FarmersInc\r\n";
$subject = "Your new account";
$mailsend=mail("$email","$subject","$emess","$ehead");
header("Location: New_member.php");
}
break;
default:
include("login_form.inc");
}
?>
Parse error: parse error in /data/hosted/oni105/Login.php on line 20
when my form looks like this
<?php
/* Program: Login.php
Desc: Login program for the Members Only section of the
wesite. 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();
session_register('auth');
session_register('username');
include("dogs.inc");
switch (@$do)
{
case "login":
$connection = mysql_connect($host, $user,$password)
or die ("Couldn't connect to server.");
$db = mysql_select_db($database, $connection)
or die (Couldn't select database.");
$sql = "SELECT loginName FROM members
WHERE loginName='$fusername'"
$result = mysql_query($sql)
or die("Couldn't execute query.");
$num = mysql_num_rows($result);
if ($num ==1) // login name was found
{
$sql = "SELECT loginName From members
WHERE loginName='$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
{
$auth="yes";
$logname=$fusername;
$today = date("Y-m-d h:m:s");
$sql = "INSERT INTO Login (loginName, loginTime)
VALUES ('$logname','$today')";
mysql_query($sql) or die(Can't execute query.");
header("Location: Member_page.php");
}
else // password is not correct
{
unset($do);
$message="The Login Name, '$fusername' exists,
but you have not entered the correct
password! Please try again.<br>";
include("login_form.inc");
}
}
elseif ($num == 0) // login name not found
{
unset($do);
$message = "The Login Name you entered does not
exist! Please try again.<br>";
include("login_form.inc");
}
break;
case "new":
foreach($HTTP_POST_VARS as $key => $value)
}
if (!ereg("^.+@.+\\..+$",$email))
{
unset($do);
$message_new = "$email is not a valid email address.
Please try again.";
include("login_form.inc");
exit();
}
/* check to see if login name already exists */
$connection = mysql_connect($host,$user,$password)
or die ("Couldn't connect to server.");
$db = mysql_select_db($database, $connection)
or die (Couldn't select database.");
$sql = "SELECT loginName FROM members
WHERE loginName='$newname'";
$result = mysql_query($sql)
or die("Couldn't execute query.");
$num = mysql_numrows($result);
if ($num > 0)
{
unset($do);
$message_new = "$newname already used. Select another
loginName.";
include("login_form.inc");
exit();
}
else
{
$today = time("Y-m-d");
$sql = "INSERT INTO members (loginName,password,firstName,
email) VALUES
('$newname','$today',password('$newpass'),
'$firstName','$email')";
mysql_query($sql);
$auth="yes";
$logname = $newname;
/* send email to new member */
$emess1=" A new member account has been setup for you. ";
$emess2="Your new loginName and password are: ";
$emess3="\n\n\t$loginName\n\t$newpass\n\n";
$emess4="I appreciate your interest in my game ";
$emess5="at http://www.hostultra.com/~oni105";
$emess6="If you have any questions or problems, email ";
$emess7="adumbleton2003@lycos.co.uk";
$emess =
$emess1.$emess2.$emess3.$emess4.$emess5.$emess6.$emess7:
$ehead="From: FarmersInc\r\n";
$subject = "Your new account";
$mailsend=mail("$email","$subject","$emess","$ehead");
header("Location: New_member.php");
}
break;
default:
include("login_form.inc");
}
?>