此登录脚本似乎不起作用。我检查了它是否通过了 if 语句,它确实通过了。还有什么问题?
处理登录的脚本:
<?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");
}
?>
检查用户是否登录的脚本index.php
:
<?
session_start();
if(!isset($_SESSION['username'])){
header("location:login.php");
}
?>