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 Like 40 Dislike
Previous forums Next forums
Other forums

j1inmis Ouput layout changes
Hi,

Can anybody tell how can j1inmis output layout can be changed so that vendor names ge

default SAP userid
hi,, I just like to know if it is ok to use the default SAP user id (SAP*)?

How to know if online site made with PHP
Hello,
I see some sites that does not display extensions at all , for example:

www.site.co

BAPI BBP_INB_DELIVERY_CREATE - material number missing in delivery
Hi Experts,

I was able to successfully create an Inbound delivery with reference to a PO

help with calculations on a flat text file
hello,
I have this code below that is attached to a flat file like this:
Email:LastName:FirstN

Best way to check for end of a record and send it back to the first record
I'm hoping someone can help me out and explain the best way to accomplish this.

What I'm doin

mySQL and PHP search
Hello,
I am trying to code a project and ran into a brick wall with one of my pages. I am pretty

Call db table from any PHP file
Hi,

I want to be able to call a database table that will be setup in another file called init

Any meaningful project for a new C++ programmer?
I want to do some meaningful program, so I can help myself to learn

Assume I know the fol

Php script to read msword file
hi,

I need to read a msword file and i want to print the contents in that word file.

i

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash