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
Windows 7
Windows 7 default user account control worries experts. Corporate IT departments should be pleased w
$variable $variables type question
I need to be able to designate an array element dynamically, so I thought to use a variable variable
Looking for help reading a .txt or .ini file and outputting the info.
I have a file called Info.ini and It has the following info:
Code: [General]
Online=0
I wou
mysql select with $_get ?
Hi, i have this code:
Code: // If char id is 0 and character dont exist do:
if ($_GET["id
Is there a quick way to do this?
Hi all,
I need to create a mysql table from php that goes a little something like this
AutoChoosing a CSS file based on URL
Hey everyone,
I have a site that has multiple URLs and CSS files.
Based on the URL tha
help with Get_
ok some how this is not working i am not sure what i am doing wrong here but what this does is when
GIS appliction help
I found some tutorials in the internet to develop a map application I don't want to use google maps
phpMailer will not connect using SMTP
I am trying to use phpMailer with smtp:
Code: [Select]$mailer = new PHPMailer();
$mailer-&
SWF image using php?
Hello once again.
My latest en devour requires me to produce an image of a static .swf that i