help me fix these syntax errors...
Posted on
16th Feb 2014 07:03 pm 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 ;
}
?>
No comments posted yet
Your Answer:
Login to answer
91
13
Other forums
Registration
ok so i have a site where people can register and login which works now thanks to someone on here th
Sorting JTable on more than just the values listed in the columns
I have a collection of objects that store (among other things) two integer values. I only want to di
tell csv import script to ignore blank rows?
Hi i have the below script but i get an error if a row is blank ie a return in the csv file at the e
Big Problem!! Please help
Hi Guys,
Im making a website for a friend have encountered a really annoying problem. When ev
Google Map
I have done Google Map Integration for one my project. But for that we need the "latitude and l
how to remove in php string display
My code is
$message="We're looking at developing our website.";
$body= "
Socket problem
Hello,
Earlier I posted about my problem with my socket script. It took up to 100% CPU usage.
convert pps to wsf with php'how?
hi
i want to convert with php
PowerPoint file to swf file(flash)
how please?
thank!!!
Applet JTextField Size Problem
Hello,
I recently started making an applet to calculate certain values for airplanes. However
Php WordPress help
I am writing the following code for making a plugin
<?php
header("Content-Type