$sql="select * from wyx_user where wyx_name='$wyx_name'&&wyx_pass='$wyx_pass'";改成
$sql="select * from wyx_user where wyx_name='$wyx_name' AND wyx_pass='$wyx_pass'";
$sql="select * from wyx_user where wyx_name='$wyx_name' AND wyx_pass='$wyx_pass'";
在php中var_dump一下$_POST['wyx_name']和$_POST['wyx_pass']、$sql
还有sql的搜索结果,看看怎么回事先。
var_dump不会用啊,菜鸟刚学
可能是你用户名或是密码错误了
结果显示:Resource id #3咋回事?
$wyx_pass = md5(trim($_POST['wyx_pass']));
$sql="select * from wyx_user where wyx_name='$wyx_name'&&wyx_pass='$wyx_pass'";
$sql=@mysql_query($sql);
$rs=@mysql_fetch_array($sql);
if($rs)
{
setcookie("wyx",$wyx_name,time()+3600000);
header("Location:admin_index.php");
}
else
{
$str="<SCRIPT language=JavaScript>alert(' 用户名或密码错误!');javascript:history.go(-1)</SCRIPT>";
echo $str;
}
include('../config.php');
//验证码
$pageRandCode=$_POST['wyx_yzm'];
session_start();
if($_SESSION['verifyCode'] <> $pageRandCode)
{
echo '<script>alert("验证码有误!");
location.replace ("index.php")</script>';
}
else
{
$wyx_name = $_POST['wyx_name'];
$wyx_pass = md5(trim($_POST['wyx_pass']));
$sql="select * from wyx_user where wyx_name='$wyx_name'and wyx_pass='$wyx_pass'";
echo $sql;
$query=@mysql_query($sql);
if($rs=@mysql_fetch_array($query))
{
setcookie("wyx",$wyx_name,time()+3600000);
header("Location:admin_index.php");
}
else
{
$str="<SCRIPT language=JavaScript>alert(' 用户名或密码错误!');javascript:history.go(-1)</SCRIPT>";
echo $str;
}
}
?>
echo $wyx_pass;结果显示的用户名和我进入phpmyadmin打开用户表里的字段内容相符啊...
$sql=@mysql_query($sql); mysql_query("set names 'gb2312'"); //要不在这里加上这句
$rs=@mysql_fetch_array($sql); echo $rs[0]."and",$rs[1]; //echo 一下看看 if($rs)
{