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...
Did you know?Explore Trending and Topic pages for more stories like this.

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

Breaking results into week blocks
I have a set of dates (and times), which are returned from a mySQL query.

These usually span

echo $rows help
Hi all,

Hopefully something simple that I don't know!

I have this:

Code: [Selec

Files in current folder. Should be an easy fix.
Never mind. I've asked about this before and just found my answer. Anyway to delete this?

I apologise! It's a newbie to PHP feedback form problem!
Hi,

I am a total newbie to PHP. I am also a unemployed and need to get a job. So after 100% r

Functions Not Loading Into Div
I had some help doing some of this but what I'm trying to do is get my functions to retrieve its val

HOW to get the bind variables list.
I've the following problem : I've some SQL queries stored in my DB as VARCHAR2 values.
I need t

php multiple action on submit
I have a form which says:

<form enctype='multipart/form-data' method='post' action='pr

User information
Hi All,
By using t-code SUIM we get all the user details,if suppose we donot have permission t

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

gmdate() - want 1 hr before time
Hi,
I am using php gmdate().
Now I am entering all dates in my dbase using gmdate("Y-m-d

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