This login script doesn't seem to work. I checked if it gets past the if statement, and it does. What else can be the problem?
the script that handles the login:
<?php
include("config.php");
$myusername=$_POST['myusername'];
$mypassword=$_POST['mypassword'];
$myusername = stripslashes($myusername);
$mypassword = stripslashes($mypassword);
$myusername = mysql_real_escape_string($myusername);
$mypassword = mysql_real_escape_string($mypassword);
$sql="SELECT * FROM " .$members. " WHERE BINARY `username`= '".$myusername."' and BINARY `password`= '".$mypassword."'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
$row = mysql_fetch_array( $result );
if($count==1){
$_SESSION['username'] = $myusername;
$_SESSION['password'] = $mypassword;
$_SESSION['privileges'] = $row['privileges'];
$_SESSION['email'] = $row['email'];
header("location:index.php");
}
?>
The script that checks if the user logged in on index.php
:
<?
session_start();
if(!isset($_SESSION['username'])){
header("location:login.php");
}
?>