从这里传过去的<form name="form1" method="post" action="chklogin.php">
<input name="name" type="text" class="logininput" id="name3" size="25">
<input name="pwd" type="password" class="logininput" id="pwd2" size="25">.......
name和psw。然后跳到下面的文件代码中:
<?php
session_start();
$A_name=$_POST['name']; //接收表单提交的用户名
$A_pwd=$_POST['pwd']; //接收表单提交的密码class chkinput{ //定义类
var $name;
var $pwd; function chkinput($x,$y){
$this->name=$x;
$this->pwd=$y;
} function checkinput(){
include("conn/conn.php"); //连接数据源
$sql=mysql_query("select * from tb_manager where name='".$this->name."' and pwd='".$this->pwd."'",$conn);
$info=mysql_fetch_array($sql); //检索管理员名称和密码是否正确
if($info==false){ //如果管理员名称或密码不正确,则弹出相关提示信息
echo "<script language='javascript'>alert('您输入的管理员名称错误,请重新输入!');history.back();</script>";
exit;
}
else{ //如果管理员名称或密码正确,则弹出相关提示信息
echo "<script>alert('管理员登录成功!');window.location='index.php';</script>";
$_SESSION[admin_name]=$info[name];
$_SESSION[pwd]=$info[pwd];
}
}
}
$obj=new chkinput(trim($name),trim($pwd)); //创建对象
$obj->checkinput(); //调用类
?>
[color=#0000FF]为什么会在 $obj=new chkinput(trim($name),trim($pwd)); 中出现错误
Notice: Undefined variable: name和Notice: Undefined variable: pwd ??[/color]
<input name="name" type="text" class="logininput" id="name3" size="25">
<input name="pwd" type="password" class="logininput" id="pwd2" size="25">.......
name和psw。然后跳到下面的文件代码中:
<?php
session_start();
$A_name=$_POST['name']; //接收表单提交的用户名
$A_pwd=$_POST['pwd']; //接收表单提交的密码class chkinput{ //定义类
var $name;
var $pwd; function chkinput($x,$y){
$this->name=$x;
$this->pwd=$y;
} function checkinput(){
include("conn/conn.php"); //连接数据源
$sql=mysql_query("select * from tb_manager where name='".$this->name."' and pwd='".$this->pwd."'",$conn);
$info=mysql_fetch_array($sql); //检索管理员名称和密码是否正确
if($info==false){ //如果管理员名称或密码不正确,则弹出相关提示信息
echo "<script language='javascript'>alert('您输入的管理员名称错误,请重新输入!');history.back();</script>";
exit;
}
else{ //如果管理员名称或密码正确,则弹出相关提示信息
echo "<script>alert('管理员登录成功!');window.location='index.php';</script>";
$_SESSION[admin_name]=$info[name];
$_SESSION[pwd]=$info[pwd];
}
}
}
$obj=new chkinput(trim($name),trim($pwd)); //创建对象
$obj->checkinput(); //调用类
?>
[color=#0000FF]为什么会在 $obj=new chkinput(trim($name),trim($pwd)); 中出现错误
Notice: Undefined variable: name和Notice: Undefined variable: pwd ??[/color]
$obj=new chkinput();
$obj->checkinput(trim($A_name), trim($A_pwd));