i am getting error at
$sql = "SELECT role FROM users WHERE username = '$username' and password = '$password'";
$result = mysql_query($sql);
as ----Query was Empty----
<html>
<body>
<form action="login.php" method="post">
<div>
<table width="100%">
<tr>
<td><img src="Logofinalcopy.gif"></td>
</tr>
<tr>
<td bgcolor="aqua"><h2>Login</h2></td>
</tr></table>
<table align="right" style="width:40%">
<br>
<tr>
<td>username:</td>
<td><input type="text" name="username"></td>
</tr>
<tr>
<td>password:</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td align="CENTER" COLSPAN="4">
<input TYPE="SUBMIT" name="submit" value="Login">
<input TYPE="reset" name="submit" value="clear"></td>
</tr>
</table>
</div>
</form>
</body>
</html>
<?php
if(isset($_POST['submit']))
{
$username=$_POST['username'];
$password=$_POST['password'];
$username = stripslashes($username);
$password = stripslashes($password);
if(strlen($username) < 1)
{
$msg=$msg."Please enter the username<br>";
$flag="NOTOK";
}
else if(strlen($password) < 1)
{
$msg=$msg."Please enter the password<br>";
$flag="NOTOK";
}
else
{
$flag="OK";
$msg="";
}
if($flag != "OK")
{
echo "<br><br><br><br><br><strong style='color:#FF3333'>"."<right>Please enter Username/Password <br></right>"."</strong>";
}
else
{
mysql_connect("10.70.1.50","invensis","invensis") or die('Could not connect: ' . mysql_error());
mysql_select_db("database_myproject") or die('Could not connect DB: ' . mysql_error());
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$sql = "SELECT * FROM users WHERE username = '$username' and password = '$password'";
$result = mysql_query($sql) or die(mysql_error());
$row_count = mysql_fetch_array($result);
$count = $row_count['count'];
if($count == 1)
{
$sql = "SELECT role FROM users WHERE username = '$username' and password = '$password'";
$result = mysql_query($sql);
$info = mysql_fetch_array($result);
if($info['role']== '0')
{
@header("location: http://localhost/Project/Superadmin.php");
}
else if($info['role']== '1')
{
@header("location: http://localhost/Project/Admin.php");
}
else if($info['role']== '2')
{
@header("location: http://localhost/Project/User.php");
}
}
else
{
echo "<br><br><br><br><br><strong style='color:#FF3333'><left>Incorrect UserName OR Password</left></strong>";
}
}
}
?>