代码:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
session_start(); //获取SESSION的userid值
$userid=$_SESSION['userid'];
$sendadd=$_POST['sendapp'];
$cardno=$_POST['cardno']; //获取提交的表单数据
$password=$_POST['password'];
$password2=$_POST['password2'];
if($sendadd=='确定'){ //单击【确定】按钮的处理
if($cardno==""){ //对表单输入的合法性检查
$msg="输入购书卡号不能为空";
echo "<meta http-equiv='Refresh' content='0;url=applycard?msg=$msg'>";
}
else if($password==""|| $password2=""){
$msg="输入购书卡密码不能为空";
echo "<meta http-equiv='Refresh' content='0;url=applycard?msg=$msg'>";
}
else if($password!=$password2){
$msg="密码输入不一致";
echo "<meta http-equiv='Refresh' content='0;url=applycard?msg=$msg'>";
} //对表单输入的合法性检查
require("opendata.php.inc"); //连接数据库,查询数据表card
$query="SELECT * FROM card WHERE cardno='$cardno'";
$result=@mysql_query($query,$connection) or die("浏览失败!2");
if($row=mysql_fetch_array($result)){ //数据表card中存在用户输入的卡号
if($row[cardstatus]=="N"){ //卡号状态不可用
$msg="该卡号不能使用!";
echo "<meta http-equiv='Refresh' content='0;url=applycard?msg=$msg'>";
}
elseif($row[cardpsd]==$password){ //卡号状态可用且用户输入的密码正确
$errmsg="申请成功!";
$query="INSERT INTO usercard (userid,password,cardno) VALUES ('$userid','$password','$cardno')";
$result=@mysql_query($query,$connection) or die("浏览失败!2");
$query="UPDATE card SET cardstatus='N' WHERE cardno='$cardno'";
$result=@mysql_query($query,$connection) or die("浏览失败!2");
echo "<meta http-equiv='Refresh' content='0;url=usercard.php?errmsg=$errmsg'>";
}
else{ //卡号状态可用且用户输入的密码不正确
$msg="密码错误,请重新输入!";
echo "<meta http-equiv='Refresh' content='0;url=applycard?msg=$msg'>";
}
}
else{ //数据表card中没有用户输入的卡号
$msg="不存在该卡号,请重新输入";
echo "<meta http-equiv='Refresh' content='0;url=applycard?msg=$msg'>";
}
}
elseif($sendapp=='跳过') header("Location:memindex.php");
$title="购书卡申请";
include_once("memhead.php");
?>
<link href="CSS/member.css" rel="stylesheet" type="text/css" /> <div id="bt">购书卡申请<hr/></div>
<div id="bd">
<div id="err"><?php echo $_SESSION['userid']; ?>->正在申请购书卡</div>
<form action="applycard.php" method="post">
<table width="100%" border="0" cellpadding="0" class="td1">
<tr><td width="30%" align="right">输入购书卡号</td><td><input type="text" name="cardno" size="30" />(位数4-30,必须由字母与数字组成)</td></tr>
<tr><td align="right">输入购书卡密码</td><td><input type="password" name="password" size="20" />(位数6-20,必须由字母与数字组成)</td></tr>
<tr><td align="right">确认购书卡密码</td><td><input type="password" name="password2" size="20"></td></tr>
<tr><td align="center" colspan="2"><input type="submit" name="sendapp" value="确定"><input type="submit" name="sendapp" value="跳过"></td></tr>
</table>
</form>
<div id="err" align="center"><?php echo $msg; ?></div> <!--反馈信息栏-->
<hr/>
<iframe scrolling="no" width="780" height="60" src="membottom.html" marginwidth="0" marginheight="0" frameborder="0" align="middle">不支持</iframe>
</div>
</body>
</html>错误提示:
Notice: Undefined index: userid in F:\xampp\htdocs\wuya\member\applycard.php on line 4Notice: Undefined index: sendapp in F:\xampp\htdocs\wuya\member\applycard.php on line 5Notice: Undefined index: cardno in F:\xampp\htdocs\wuya\member\applycard.php on line 6Notice: Undefined index: password in F:\xampp\htdocs\wuya\member\applycard.php on line 7Notice: Undefined index: password2 in F:\xampp\htdocs\wuya\member\applycard.php on line 8Notice: Undefined variable: sendapp in F:\xampp\htdocs\wuya\member\applycard.php on line 48
Notice: Undefined index: userid in F:\xampp\htdocs\wuya\member\applycard.php on line 56
Notice: Undefined variable: msg in F:\xampp\htdocs\wuya\member\applycard.php on line 65
有没有办法可以通解这类问题~
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
session_start(); //获取SESSION的userid值
$userid=$_SESSION['userid'];
$sendadd=$_POST['sendapp'];
$cardno=$_POST['cardno']; //获取提交的表单数据
$password=$_POST['password'];
$password2=$_POST['password2'];
if($sendadd=='确定'){ //单击【确定】按钮的处理
if($cardno==""){ //对表单输入的合法性检查
$msg="输入购书卡号不能为空";
echo "<meta http-equiv='Refresh' content='0;url=applycard?msg=$msg'>";
}
else if($password==""|| $password2=""){
$msg="输入购书卡密码不能为空";
echo "<meta http-equiv='Refresh' content='0;url=applycard?msg=$msg'>";
}
else if($password!=$password2){
$msg="密码输入不一致";
echo "<meta http-equiv='Refresh' content='0;url=applycard?msg=$msg'>";
} //对表单输入的合法性检查
require("opendata.php.inc"); //连接数据库,查询数据表card
$query="SELECT * FROM card WHERE cardno='$cardno'";
$result=@mysql_query($query,$connection) or die("浏览失败!2");
if($row=mysql_fetch_array($result)){ //数据表card中存在用户输入的卡号
if($row[cardstatus]=="N"){ //卡号状态不可用
$msg="该卡号不能使用!";
echo "<meta http-equiv='Refresh' content='0;url=applycard?msg=$msg'>";
}
elseif($row[cardpsd]==$password){ //卡号状态可用且用户输入的密码正确
$errmsg="申请成功!";
$query="INSERT INTO usercard (userid,password,cardno) VALUES ('$userid','$password','$cardno')";
$result=@mysql_query($query,$connection) or die("浏览失败!2");
$query="UPDATE card SET cardstatus='N' WHERE cardno='$cardno'";
$result=@mysql_query($query,$connection) or die("浏览失败!2");
echo "<meta http-equiv='Refresh' content='0;url=usercard.php?errmsg=$errmsg'>";
}
else{ //卡号状态可用且用户输入的密码不正确
$msg="密码错误,请重新输入!";
echo "<meta http-equiv='Refresh' content='0;url=applycard?msg=$msg'>";
}
}
else{ //数据表card中没有用户输入的卡号
$msg="不存在该卡号,请重新输入";
echo "<meta http-equiv='Refresh' content='0;url=applycard?msg=$msg'>";
}
}
elseif($sendapp=='跳过') header("Location:memindex.php");
$title="购书卡申请";
include_once("memhead.php");
?>
<link href="CSS/member.css" rel="stylesheet" type="text/css" /> <div id="bt">购书卡申请<hr/></div>
<div id="bd">
<div id="err"><?php echo $_SESSION['userid']; ?>->正在申请购书卡</div>
<form action="applycard.php" method="post">
<table width="100%" border="0" cellpadding="0" class="td1">
<tr><td width="30%" align="right">输入购书卡号</td><td><input type="text" name="cardno" size="30" />(位数4-30,必须由字母与数字组成)</td></tr>
<tr><td align="right">输入购书卡密码</td><td><input type="password" name="password" size="20" />(位数6-20,必须由字母与数字组成)</td></tr>
<tr><td align="right">确认购书卡密码</td><td><input type="password" name="password2" size="20"></td></tr>
<tr><td align="center" colspan="2"><input type="submit" name="sendapp" value="确定"><input type="submit" name="sendapp" value="跳过"></td></tr>
</table>
</form>
<div id="err" align="center"><?php echo $msg; ?></div> <!--反馈信息栏-->
<hr/>
<iframe scrolling="no" width="780" height="60" src="membottom.html" marginwidth="0" marginheight="0" frameborder="0" align="middle">不支持</iframe>
</div>
</body>
</html>错误提示:
Notice: Undefined index: userid in F:\xampp\htdocs\wuya\member\applycard.php on line 4Notice: Undefined index: sendapp in F:\xampp\htdocs\wuya\member\applycard.php on line 5Notice: Undefined index: cardno in F:\xampp\htdocs\wuya\member\applycard.php on line 6Notice: Undefined index: password in F:\xampp\htdocs\wuya\member\applycard.php on line 7Notice: Undefined index: password2 in F:\xampp\htdocs\wuya\member\applycard.php on line 8Notice: Undefined variable: sendapp in F:\xampp\htdocs\wuya\member\applycard.php on line 48
Notice: Undefined index: userid in F:\xampp\htdocs\wuya\member\applycard.php on line 56
Notice: Undefined variable: msg in F:\xampp\htdocs\wuya\member\applycard.php on line 65
有没有办法可以通解这类问题~
$userid=isset($_SESSION['userid'])?$_SESSION['userid']:"";
修改一下php.ini,搜索error_reporting,把它修改成E_ALL & ~E_NOTICE就行了,记得重启apache
function post($n){
return isset($_POST[$n]) ? $_POST[$n] : null;
}
$password=post('password');