Hunter
March 13th, 2010, 09:31 PM
I don't see a problem in the code :/
Error:
Parse error: syntax error, unexpected '{', expecting '(' in /home/a9012858/public_html/admin/scripts/check_login.php on line 29
PHP:
<?php
session_start();
//Database connection
$dbhost = "hostname";
$dbuser = "username"; //Database username goes here
$dbpass = "password"; //Database password goes here
$dbname = "databasename"; //Database name
//Connect to database and set status variable for later use
$con = mysql_connect($dbhost, $dbuser, $dbpass);
if (!$con) {
$mess = "Error connecting to database! Error: ".mysql_error(); // Error connection to mysql database
header("Location:../login.php?mess=$mess");
}
$uname= $_POST['username'];
$pword= md5($_POST['password']);
$remMe= $_POST['rememberme'];
if ($uname == "" || $uname == NULL) {
$mess = "Please enter your username!"; // No username has been entered
header("Location:../login.php?mess=$mess");
}
elseif ($upass == "" || $upass == NULL) {
$mess = "Please enter your password!"; //No password has been entered
header("Location:../login.php?mess=$mess");
} //LINE 29 IS HERE BY THE WAY ################################################## ###################
elseif {
//Tests have been passed
mysql_select_db($dbname, $con);
$query=mysql_query("SELECT * FROM users");
//Check if username and password matchs
while ($row=mysql_fetch_array($query)) {
$username=$row['username'];
$password=$row['password'];
if ($uname == $username && $pword == $password) {
// Username and password matches, make session variables
$_SESSION['username']=$uname;
$_SESSION['password']=md5($pword);
//Check is remember password has been set
if ($remMe==1) {
//Create cookies
setcookie("user", "$uname".md5($pword), time()+0*0*0*7); //Should set the cookie to expire in a week
}
//Now redirect to main page
$mess = "Login successfull!";
header("Location:../index.php?mess=$mess")
}
} //END While
}
?>
Error:
Parse error: syntax error, unexpected '{', expecting '(' in /home/a9012858/public_html/admin/scripts/check_login.php on line 29
PHP:
<?php
session_start();
//Database connection
$dbhost = "hostname";
$dbuser = "username"; //Database username goes here
$dbpass = "password"; //Database password goes here
$dbname = "databasename"; //Database name
//Connect to database and set status variable for later use
$con = mysql_connect($dbhost, $dbuser, $dbpass);
if (!$con) {
$mess = "Error connecting to database! Error: ".mysql_error(); // Error connection to mysql database
header("Location:../login.php?mess=$mess");
}
$uname= $_POST['username'];
$pword= md5($_POST['password']);
$remMe= $_POST['rememberme'];
if ($uname == "" || $uname == NULL) {
$mess = "Please enter your username!"; // No username has been entered
header("Location:../login.php?mess=$mess");
}
elseif ($upass == "" || $upass == NULL) {
$mess = "Please enter your password!"; //No password has been entered
header("Location:../login.php?mess=$mess");
} //LINE 29 IS HERE BY THE WAY ################################################## ###################
elseif {
//Tests have been passed
mysql_select_db($dbname, $con);
$query=mysql_query("SELECT * FROM users");
//Check if username and password matchs
while ($row=mysql_fetch_array($query)) {
$username=$row['username'];
$password=$row['password'];
if ($uname == $username && $pword == $password) {
// Username and password matches, make session variables
$_SESSION['username']=$uname;
$_SESSION['password']=md5($pword);
//Check is remember password has been set
if ($remMe==1) {
//Create cookies
setcookie("user", "$uname".md5($pword), time()+0*0*0*7); //Should set the cookie to expire in a week
}
//Now redirect to main page
$mess = "Login successfull!";
header("Location:../index.php?mess=$mess")
}
} //END While
}
?>