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

calendar dates and hours compare problem
i have a calendar in wordpress, everything works great except that i can make 2 meetings at the same

login from external site
Hi my new experience begins, Now what i am trying to do is i make three pages, login.php logout.php

CE 7.1 and External GIS integration
Hi All,

We want to develop an application on CE 7.1 which uses GIS features from an exter

whats wrong with my code please help!!!
this is the error


Warning: mysql_close(): supplied argument is not a valid MySQL-Link res

Upload file and add HTML
Hey everyone,

I have a client has meeting agendas and minutes that should be posted online. I

upload form file types....
Hey all, I am learning PHP and I am writing a script from the W3C Schools tutorials for uploading fi

retrieving more than one max key from an array?
so i have an array of 20 numerical values (0-100) that i need to order from highest to lowest and th

Quick Syntax Question
Hi folks,

I'm getting the following error: "unexpected T_LNUMBER". I'm trying to b

How to schedule the a job?
Hi,
I have prepared a task ( i.e. a procedure is prepare the file and send the same to con

How can use this array as a key?
Say I have this array for example:


print_r($array);

Prints:
Code: [Select]Array

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