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

Xml parsing
I need a suggestion about parsing xml with multiply parts like pervious...
i.e. different device

License Issue - service type user
Hi,

I would like to understand the following issue regarding sap license.
I wish to

Include ("Absolute Path") of a file?
I'm not sure what I'm doing wrong. I am writing my php code in the same directory of the file that

Record count of entire database
Does anyone know if there is a way to obtain the number of records in each table of the database usi

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
what is wrong with this

Code: [Select]<?php
if ($_SERVER['HTTP_REFERER'])
{

Question about the upload of large files
Hi there,

I have a question about the upload of large files, like videos (files generally abo

Syntax Help
I'm trying to make a form that edits a php file which contains config settings. I'm using strings t

FILTER_CALLBACK -- Files?
Hi All,

I'm using the php filter functions to validate my form data. For custom filters, I'm

What is SAP Avatar ?
Hi All,

This G.Satish , my boss asked me to explore on SAP Avatar. I searced in internet

Sending a hyperlink through mail
HI all,
I am sending a mail to outlook mailbox of a user using FM SO_NEW_DOCUMENT_ATT_S

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