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
MS Access data into a html table
Hi everyone, I am quite a novice at php but I have created some helpful scripts that fetch data
f
a function to check directory depth
I'm working on a php script to upload files in to a set directory.
the user can select to upload
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
Display the user's weight lost in the past week
Hello everyone,
I am working on a weight loss app for my site, and I want to display the user
SESSION question
I am building an application , a directory for auctions.
For SEO i made a script which copies a p
Why use interfaces in PHP (OOP)
I am learning OOP in PHP and its been a pretty good learning experience so far. What I didn't unders
Whats wrong with my query?
I am trying to get this query to show the appropriate ticked vehicle roof height, unless no boxs are
urldecode question
How would I format this line of code properly?
<?php echo urldecode($_GET['Title']); ?
Load file in PHP
I have 2 files. The first is a PHP generated XML file that's dependent by 2 inputs. The second is a
wav to mp3 + goDaddy
I need to convert wav files to mp3s. From what I have found so far one way to do it is to have my PH