退选课程提交后,系统提示错误,第15、35、38行有未定义的变量“xuehao” 请问我应该怎么修改?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>退选课题</title>
</head><body>
<?php 
//######################退选课题界面3##########################
 include "config.php";
 include "header.php";?>
<?php
 extract($_POST);
        $query="select * from $student_table where xuehao='".$xuehao."'";
mysql_query("set names 'GB2312'");
$result=mysql_query($query);
$row=mysql_fetch_array($result);
$id=$row['id']; $query1="select number as sn,surplus as ssn from $jiaoshi_table where id='$id'";
mysql_query("set names 'GB2312'");
$result1=mysql_query($query1);
$row1=mysql_fetch_array($result1);
if($row1['sn']==1)
{
    $query2=mysql_query("update $jiaoshi_table set xuehao='未选' where id='$id'");
$query3=mysql_query("update $jiaoshi_table set surplus=surplus+1 where id='$id'");
}
else
{
     if(($row1['sn']-$row1['ssn'])==1)
     $query7=mysql_query("update $jiaoshi_table set xuehao='未选' where id='$id'");
 else
      $query6=mysql_query("update $jiaoshi_table set xuehao=replace(xuehao,concat('".$xuehao."','\n'),'') where id='$id'");
 $query8=mysql_query("update $jiaoshi_table set surplus=surplus+1 where id='$id'");

    $query5="update $student_table set id=0 where xuehao='".$xuehao."'";
mysql_query("set names 'GB2312'");
$result5=mysql_query($query5);
if($result5==true)
{
   echo"<p align=\"center\"><font color=\"#FF0000\"><b><big>退选课题成功!</big></b></font>";
   echo "<meta http-equiv=\"refresh\" content=\"2;url=back_keti.php\">";
   exit;
     }
 else
 {
           echo"<p align=\"center\"><font color=\"#FF0000\"><b><big>退选出错,请返回重新退选</big></b></font></p>";
           echo "<meta http-equiv=\"refresh\" content=\"1;url=back_keti.php\">"; 
           exit;
         }
 }?>
<?php include "foot.php";?>
</body>
</html>

解决方案 »

  1.   

    看你前一个页面的form表单都有什么
      

  2.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>退选课题</title>
    <style type="text/css">
    <!--
    .STYLE1 {font-size: 14px}
    -->
    </style>
    </head><body>
    <?php 
    //######################退选课题界面2##########################
      include "config.php";
      include "admin_header.php";
     ?>
     <?php
     extract($_POST);
      if ($xuehao=="" || $id=="") 
     {
    echo"<p align=\"center\"><font color=\"#FF0000\"><b><big>请把信息填写完整。</big></b></font></p>";
    echo "<meta http-equiv=\"refresh\" content=\"1;url=back_keti.php\">";
    exit;
     }  
      
       else
       
     $query="select * from $student_table where xuehao='$xuehao'";
     mysql_query("set names 'GB2312'");
     $result=mysql_query($query);
     $row=mysql_fetch_array($result);
     if($row==0)
     {
    echo"<p align=\"center\"><font color=\"#FF0000\"><b><big>你的输入有误,请重新输入。</big></b></font></p>";
    echo "<meta http-equiv=\"refresh\" content=\"2;url=back_keti.php\">";
        exit;
     }
     
     $query="select id as sm from $student_table where xuehao='$xuehao'";
     mysql_query("set names 'gb2312'");
     $result=mysql_query($query);
     $row=mysql_fetch_array($result);
     if($row['sm']==0)
     {
    echo"<p align=\"center\"><font color=\"#FF0000\"><b><big>你还没有选择课题!</big></b></font></p>";
    echo "<meta http-equiv=\"refresh\" content=\"2;url=back_keti.php\">";
        exit;
     }
     
     
     $query="select * from $jiaoshi_table where id='$id'";
     mysql_query("set names 'gb2312'");
     $result=mysql_query($query);
     $row=mysql_fetch_array($result);
     if($row==0)
     {
    echo"<p align=\"center\"><font color=\"#FF0000\"><b><big>课题号不存在,请重新输入!</big></b></font></p>";
    echo "<meta http-equiv=\"refresh\" content=\"2;url=back_keti.php\">";
        exit;
     }
     ?>
    <table width="700" border="0" cellspacing="1" cellpadding="0" bgcolor="#333333" align="center">
      <tr> 
      <td width="78" height="30" bgcolor="#FFFFFF"> 
          <div align="center" class="text"> 
            <p class="STYLE1">学生学号</p>
          </div>
        </td>
        <td width=97 height="30" bgcolor="#FFFFFF"> 
          <div align="center" class="STYLE1">学生姓名</div>
        </td>
        <td width="329" height="30" bgcolor="#FFFFFF"> 
        <div align="center" class="STYLE1"> 课题名称 </div>    </td>
        <td width=106 height="30" bgcolor="#FFFFFF"> 
          <div align="center" class="STYLE1">指导教师</div>
        </td>
        <td width=84 height="30" bgcolor="#FFFFFF"> 
        <div align="center" class="STYLE1">职称</div>    </td>
    <td width=84 height="30" bgcolor="#FFFFFF"> 
        <div align="center" class="STYLE1">退选</div>    </td>
      </tr> 
      <?php 
      $n=0; 
       $query=mysql_query("select * from $jiaoshi_table,$student_table where $jiaoshi_table.id=$student_table.id and $student_table.xuehao='$xuehao'");
       mysql_query("set names 'gb2312'");
       while($row=mysql_fetch_array($query)){
            if(($n%2)!='0'){
        echo "<tr bgcolor=#FFFFff>";}
      else{
      echo "<tr bgcolor=#E4E4E4>";
      }
         echo"
     <td   height='22' class='STYLE1'> <div align='center'>".$row['xuehao']."</div></td>
     <td   height='22'> 
    <div align='center' class='STYLE1'>".$row['name']."</div></td>
        <td   height='22' class='STYLE1'> <div align='center'>".$row['subject']."</div></td>
        <td   height='22' class='STYLE1'> <div align='center'>".$row['teacher']."</div></td>
    <td   height='22' class='STYLE1'> <div align='center'>".$row['zhicheng']."</div></td>
    <td   height='22' class='STYLE1'><div align='center'>
    <a href=back_keti2.php?xuehao=".$row['xuehao']." >退选</a></div></td>
      </tr> ";
       $n++;
       }
     ?></table>
     <p>
    <?php include "foot.php";?>
      

  3.   

    <a href=back_keti2.php?xuehao=".$row['xuehao']." >退选</a>
    兄弟,这不是GET提交吗?那边用POST接受???会出问题吧
      

  4.   

    惭愧啊,意思是我把POST改成GET?
      

  5.   

    要是改了的话,back_keti2.php中其他的变量就没发获取了吧。
    我看了一下,back_keti2.php里除了变量$xuehao也没什么其他的了。
    改一下试试吧,我认为应该可以用
      

  6.   

    在back_keti2.php先var_dump一下$_GET吧。。
    PS: 我好奇,退课的页面只传了一个学号变量,back_keti2.php怎么知道要退哪门课程
      

  7.   

    我不懂语法,只是把POST改为了GET。正确的语句应该是怎样的?
      

  8.   

    echo "<meta http-equiv=\"refresh\" content=\"2;url=back_keti.php\">";
    这句话是自动跳转的意思。
    我估计是你成功了。但是看不到成功。因为成功之后接着马上就跳到back_keti.php了
      

  9.   

    没有,它就停留在那一页,地址栏里是back_keti2.php?xuehao=我输入的学号
    我就是把extract($_POST);改成extract($_GET);对吗?
      

  10.   

     <?php
    var_dump($_GET);
    ?>
    接受界面头部加一个这个,看有没有结果
      

  11.   

    不报错了,但是页面是空白的,什么也不显示。再查询一下,发现退选的课程还在。改了之后,结果是这样的array (size=1)
      'xuehao' => string '我输入的学号' (length=9)
      

  12.   

    获取值那里应该都没有错了。
    问题就在第二页的几个SQL语句上了吧。
    没走到最下面的if语句。
    中间的sql语句不清楚变量,看不懂。
      

  13.   

    extract($_REQUEST);
    $_POST 和 $_GET 的内容都包括在 $_REQUEST 中,没有特别的要求,不需要分得那么细你只是 <a href=back_keti2.php?xuehao=".$row['xuehao']." >退选</a>
    只传递了学号,并没有传递课程并没有看到你是如何实现“退选”的代码
      

  14.   

    我退选的代码就是那几条update语句,貌似就是我第15,35,38行的问题,总是提示我“Undefined variable:xuehao”是不是我的书写格式有问题?