>我正在使用php脚本进行登录,它在我的本地主机(apache2,OS:ubuntu)上完全有效但是当我把它放到网上时不起作用
这里附上了PHP代码
<?php
include('config.php');
session_start();
if($_SERVER["REQUEST_METHOD"]=="POST")
{
$myusername=addslashes($_POST['user_name']);
$mypassword=addslashes($_POST['pass_word']);
$mypassword=md5($mypassword);
$sql="select id from userinformation2 WHERE username='$myusername' and password='$mypassword' ";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
$active=$row['active'];
$count=mysql_num_rows($result);
if($count==1)
{
session_register("myusername");
$_SESSION['login_user']=$myusername;
header("location:welcome.php");
}
else
{
$error="name and password is invalid";
echo $error;
}
}
?>
如果实时数据库正在获取多个ID和密码记录,可能会导致问题,因为条件是$count==1,如果mysql_num_rows($result)大于1,那么它就不会落在条件中,并且有一件事表明为什么你不使用isset条件