help me fix these syntax errors...

Posted on 16th Feb 2014 by admin

I keep getting multiple syntax errors on this script like this one:

Parse error: syntax error, unexpected T_ELSE in .../scripts/php/loginform2.php on line 40

when I change that line I get another on line 33...

Can someone please help me with this script?

Thanks,

kaiman

Code: [Select]<?php
// connects to server and selects database.
include ("dbconnect.inc.php");

// table name
$tbl_name="registered_members";

// removes magic_quotes_gpc slashes
function stripQuotes($arg) {
if (get_magic_quotes_runtime()) {
return stripslashes($arg);
} else {
return $arg;
}
}

// protect against mysql injection
function cleanString($string){
htmlentities(mysql_real_escape_string($string));
return $string;
}

// username and password sent from login form
$username = stripQuotes($_POST['username']);
$username = cleanString($_POST['username']);
$pass = sha1($_POST['pass']);

// select info from database
$sql="SELECT * FROM $tbl_name WHERE username='$username' and password='$pass'";
$result=mysql_query($sql);

// mysql_num_row counts the table row
$count=mysql_num_rows($result);

// if result matched $username and $pass, table row must be 1 row
if($count==1){

// register $_SESSION
session_start();
$_SESSION['username'] = $username;
$_SESSION['pass'] = $pass;
$_SESSION['id'] = $row['id'];
$_SESSION['level'] = $row['level'];
else {
echo "Incorrect Username or Password";
exit ;
}

// user levels

// 0 = guest
// 1 = user - default
// 2 = auther
// 3 = moderator
// 4 = admin
// 5 = banned user

// check user levels
if ($_SESSION['level'] == '1') {
header("Location: http://www.example.com/user/");
}
if ($_SESSION['level'] == '2') {
header("Location: http://www.example.com/author/");
}
if ($_SESSION['level'] == '3') {
header("Location: http://www.example.com/moderator/");
}
if ($_SESSION['level'] == '4') {
header("Location: http://www.example.com/admin/");
}
}
else {
echo "You Don't Have Permission to View This Page";
exit ;
}
?>

Other forums