php登入错误高手指点下

来源:百度知道 编辑:UC知道 时间:2024/06/05 12:14:18
<?php
session_start();

class chkuserlogin{

private $usernc;
private $userpwd;
private $xym;

public function __construct($usernc,$userpwd,$xym){
$this->usernc=$username;
$this->userpwd=$userpwd;
$this->xym=$xym;
}

public function chk(){
if(trim($this->xym)!=trim($_SESSION["autonum"])){
echo "<meta http-equiv=\"refresh\" content=\"1;url=index2.php\">3秒钟后转入前页,请稍等......";
exit;
}else{
include_once("conn.php");
$sql=mysql_query("select usernc,userpwd from tb_user where usernc='".$this->usernc."'and userpwd='".$this->userpwd."'",$conn);
$info=mysql_fetch_array($sql);
if($info){
echo "<script>alert('登录成功!');</script>";
}else

我感觉你的引号用的太多了,你换成这样试试
$sql=mysql_query("select usernc,userpwd from tb_user where
usernc=".$this->usernc." and userpwd=".$this->userpwd."",$conn);
或者是这样=mysql_query('select usernc,userpwd from tb_user where
usernc=".$this->usernc." and userpwd=".$this->userpwd."',$conn);

把这句$info=mysql_fetch_array($sql); 换成这个就OK了$info=mysql_num_rows($sql);