Problem with PHP/mySQL login code
Posted on
16th Feb 2014 07:03 pm by
admin
Hello,
There is an error in my login script and I can't figure out what it is...
I believe it might be my "SELECT" statement...
Can anyone help me?
Code: <?php
//define ('SASI Services Portal');
//check if user is logged in
$loggedin==0;
if(isset($_POST['username']))
{
$loggedin=FALSE; //the user is not currently logged in
//so, open the mysQL database
//create the connection
$con=mysql_connect("localhost", "xxxx", "xxxx");
if(!$con)
{
die('Could not connect: ' .mysql_error());
}
mysql_select_db("my_SASI", $con);
$result= mysql_query("SELECT * FROM logins, users WHERE logins.loginID=users.userID AND Email_Address='".$_POST['username']."' AND password='".$_POST['password']."' AND accessLevel=1");
while($row=mysql_fetch_array($result))
{
session_start(); //start a new session
$_SESSION['username']=$_POST['username'];
$_SESSION['password']=$_POST['password'];
$_SESSION['firstname']=$row['FirstName'];
$_SESSION['lastname']=$row['LastName'];
$_SESSION['accesslevel']=$row['accessLevel'];
$loggedin=TRUE;
}
}
if($loggedin && $_SESSION['accesslevel']==0)
{
header('Location: student_admin.php');
exit();
}
if($loggedin && $_SESSION['accesslevel']==1)
{
header('Location: teacher_admin.php');
exit();
}
mysql_close($con);
?>
No comments posted yet
Your Answer:
Login to answer
344
40
Other forums
TemplatePower & AJAX
Hi all,
I'm currently implementing some AJAX features in my PHP-framework (which is b
. and .. appearing instead of pictures
First of all, thanks very much for providing this forum. It is very much appreciated!
My son
.htpasswd Registration Form
Hi,
I wanted to make an htpasswd registration form.
I found this code on the internet but have
How to display random record from table?
I have the following code:
Code: <?php
$display_block .= "<input type=
Adding to the next element in a multidimensional array
Hi, I'm trying to add a value to $node->field_spaces['nid'] where x is the next available spo
SAP BCS. BPS
Hi all,
I am seeking reading note on the following in BW
BCS, BPS
ADVANCE
Create PHP table grid help, please
I have a MySQL database setup, now it's time for the table (gridview) design in php. Here's the prob
Creating a function
Basically i wanna put all this code in a seperate file
Code: <?php
Must-Know Topics of PHP
Can you guys list the must-know topics of PHP. I am still a learner and I am trying to cover most of
Page Reload
I am having issues getting a page to reload after I submit data to a database. This form should inp