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
Find only certain URLs from page ... regex (semi-complete script)
Hi guys,
What I need to do is take a page & extract all the URLs from the page &a
phpmailer class & pop.gmail.com?
Code: <?php
$mail->IsSMTP();
$mail->Host = "pop.gmail.com";
PHP Surveys
I really would like some advice.
If you have a client come to you asking for a survey to be d
How to kill asynchronous postback / current postback?
Hi,here is my problem:I have a web site with many pages of which some may take time to process resul
want a code for uploading and downloading
i m trying to upload and download to my site..i need upload and download code ...i use a code for up
How to secure my login data to my database?
Hi there,
It may be a stupid question but I don't know how to secure my login data to my data
The type or namespace name 'ServiceModel' does not exist in the namespace 'System'
When I locally run the website, it works just fine, but when I uploaded it to the hosting environmen
Where do I put CRON code
So I've figured out alot about how to automatically run a php function. I can't figure out where to
Form help: Syntax & Logic
Hello again all,
I'm working on a form and ran into a wall (again) and can't seem to think th
media recovery
Hi,
i startup the database i got the error
SQL> startup
ORACLE instance started.