代码:
<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

有没有办法可以通解这类问题~

解决方案 »

  1.   

    你这个是变量没有定义 ;一般 可以采用 
    $userid=isset($_SESSION['userid'])?$_SESSION['userid']:"";
      

  2.   

    Notice 只是提示 不是错误.如果你觉得不顺眼可以修改php.ini 错误的提示级别更换成其他类型
      

  3.   

    这个和你程序没有关系,只是你把php.ini的安全级别调的太高了,这个应该是notice级别的错误(不是错误,因为程序还在运行)
    修改一下php.ini,搜索error_reporting,把它修改成E_ALL & ~E_NOTICE就行了,记得重启apache 
      

  4.   

    我还想问一下,如果取消了所有的Notice通知,那么对程序会不会产生什么影响~
      

  5.   

    当然对程序的运行会有影响,如果你的程序不允许变量值为空的话你只需对所有的外部变量都 isset() 一下就“健壮”了
      

  6.   

    error_report();可以设置 你的错误级别;或者是通过set_ini()来设置 php.ini 里面的参数;这样做的好处就是不用去修改 php.ini 的文件
      

  7.   


    function post($n){
      return isset($_POST[$n]) ? $_POST[$n] : null;
    }
    $password=post('password');
      

  8.   

    我也用过isset(),可是它还是显示Nctice通知,是不是我用错了?求解~