Does the query succeed?
You could try checking with:
[php]$select=“SELECT * FROM USERS where username=’”.$user."’ && password=’".$pass."’";
$msq=mysql_query($select);
if($msq == false) {
echo mysql_error();
}[/php]
Also, you should always sanitize your user input before putting it into an SQL statement:
[php]$user=mysql_real_escape_string($_POST[‘username’]);
$pass=mysql_real_escape_string($_POST[‘password’]);[/php]
In addition to that - as you’re only expecting one record result - you don’t need the while statement:
[php] if(mysql_num_rows($msq)>0)
{
while($row=mysql_fetch_array($msq))
{
$username=$row[‘users’];
$_SESSION[‘username’]=$username;
echo $_SESSION[‘username’];
}
header("location: checkuser.php");
}}[/php]
Can become:
[php]if(mysql_num_rows($msq)>0) {
$row=mysql_fetch_array($msq);
$username=$row[‘users’];
$_SESSION[‘username’]=$username;
echo $_SESSION[‘username’];
header(“location: checkuser.php”);
}[/php]
@vivekanand pathak please put your code in PHP tags. Use the php button above the form that you use to create a new thread or reply.