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
40
Other forums
IIS & NW MII on the same server
Hi,
We're weighing the possibility to run both IIS and MII (NetWeaver) on the same server
Question about ShowWindow()
Hello....
I'm struggling with sumpin, and I hope y'all can help.
I've got a CFormView
Internal class functions don't seem to get executed.
Hi. Can someone please put me out of my misery on this. I don't write much PHP and this has me baffl
FROM_UNIXTIME($phpdate);
Hello,
I tried to use this :
$date = FROM_UNIXTIME($phpdate);
ANd I was t
SCO Unix
I know this might not be the place to ask, but, can anyone tell me if SCO Unix comes with PHP built
Web Host List
Here is a list of web hosts that offer PHP and MySQL. It is no where near a full list, but it is mos
Problem with an browser game.
Hello,i just joined that great forum and i got php prob,its kinda freaky...anyway i got browser game
Image DPI
Hi.
I allow users to upload images, the user then is able to adjust several settings for the
Gantt Chart Tool
Does anyone know of a good free gantt chart creator tool
Thanks
Send inserts to mysql thru port 80
Hi!
I have an application that must do some inserts in a mysql db. This db is behind a firewa