Joined: 31 Jul 2004 |
Posts: 1 |
|
|
|
Posted: Fri Jul 30, 2004 2:23 pm |
|
|
|
|
|
Hello, I have a problem with a code and I would like it if someone our somebody could help me. When I save this file and open it in the mozilla webbrowser it says:
Parse error: parse error, unexpected T_VARIABLE in /var/www/html/Login.php on line 159.
I have been looking for a very long time and would like some help on it.
Thanks,
Dylan
<?php
/* Program: Login.php
* Desc: Login program for the members only section of
* Chatspeak. it provides two options: (1) login
* using existing Login Name and (2) enter a new
* loin name. Login Names and passwords are stored
* in MySQL database.
*/
session_start();
include("dogs.inc");
switch (@$_GET['do'])
{
case "login":
$connection = mysql_connect($host, $user,$password)
or die ("couldn't connect to server.");
$db = mysql_select_db($database, $connection)
or die ("coudn't select database.");
$sql = "SELECT loginName FROM Member
WHERE loginName ='$_POST[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 Member
WHERE loginName='$_POST[fusername]'
AND password=password('$_POST[fpassword]')";
$result2 = mysql_query ($sql)
or die ("coudn't execute query 2.");
$num2 = mysql_num_rows($result2);
if ($num2 > 0) // password is correct
{
$_SESSION['auth']="yes";
$logname=$_POST['fusername'];
$_SESSION['logname'] = $logname;
$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
{
unset($do);
$message="The username and/or password is incorrect!
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 in our database!
Please try again.<br>";
include("login_form.inc");
}
break;
case "new":
foreach($_POST as $feild => $value)
{
if ($feild != "fax")
{
if ($value == "")
{
unset($_GET['do']);
$message_new = "Required inforomation is missing.
Please try again.";
include("login_form.inc");
exit();
}
}
if (ereg("(Name)",$feild))
{
/*if (!ereg(!^("^[A-Za-z' -]{1,50}$",$value))
{
unset($_GET['do']);
$message_new = "$feild is not a valid name.
Please try again.";
include("login_form.inc");
exit();
}*/
}
$$feild = strip_tags(trim($value));
} //end foreach
if (!ereg("^[0-9]{5,5}(\-[0-9]{4,4})?$",$zip))
{
unset($_GET['do']);
$message_new = "$zip is not a valid zip code.
Please try again.";
include("login_form.inc");
exit();
}
if (!ereg("^[0-9])(xX -]{7,20}$",$phone))
{
unset($_GET['do']);
$message_new = "$phone is not a valid phone number.
Please try again.";
include("login_form.inc");
exit();
}
if ($fax != "")
{
if (!ereg("^[0-9)(xX -]{7-20}$",$fax))
{
unset($_GET['do']);
$message_new = "$fax is not a valid phone number.
Please try again.";
include("login_form.inc");
exit();
}
if (!ereg("^.+@.+.+\\..+$",$email))
{
unset ($_GET['do']);
$message_new ="$email is not a valid email address.
Please try again.";
include("login_form.inc");
exit();
}
/*Chechk to see if login name exists*/
$connection = mysql_connect($host, $user,$password)
or die ("coudn't connect to server.");
$db = mysql_select_db($database, $connection)
or die ("Couldn't select db.");
$sql = "SELECT loginName FROM Member
WHERE loginName='$newname'";
$result = mysql_query($sql)
or die("couldn't execut query.");
$num = mysql_numrows($result);
if ($num > 0)
{
unset($_GET['do']);
$message_new = "$newname already used. Select another
username.";
include("login_form.inc");
exit();
}
else
{
$today = date("y-m-d");
$sql = "INSERT INTO Member (loginName,createDate,
password,firstName,lastName,street,city,
state,zip,phone,fax,email) VALUES
'$newname','$today' ,password('$newpass')
'$firstName', '$lastName','$street','$city',
'$state','$zip','$phone','$fax','$email')";
mysql_query($sql);
$_SESSION['auth']="yes";
$_SESSION['logname'] = $newname;
/* send email to new member */
$emess = "A new member account has been setup. ";
$emess.= "your new username and password are: ";
$emess.= "n\n\t$newname\n\t$newpass\n\n";
$emess.= "We appreciate your inrest in the Living room boutique";
$emess.= " at Livingroomboutiqe.com. \n\n";
$emess.= "If you have any questions coments or problems,";
$emess.= " email larry@livingroomboutique.com"
$ehead="From: larry at larry@livingroomboutique.com\r\n";
$subj = "Your new member account from livingroomboutique.com";
$mailsend=mail("$email","$subj","$emess","$ehead");
header("location: New_member.php");
}
break;
default:
include("login_form.inc");
}
?> |
|