PHP,POST页面无法传值跳转,请大神帮助。

Index.php文件

<!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_chinese_ci" />
<title>学生信息收集系统</title>
<script language="javascript" type="text/javascript" >
function check_form(){
    if(form1.tb_user.value==""){
        alert("请填写学籍号!");
        form1.tb_user.select();
        return (false);
        }
    if(form1.tb_passWord.value==""){
        alert("请填写密码!");
        form1.tb_passWord.select();
        return (false);
        }
    }
</script>
</head>
<body>
<center>
<h1><font color="#003333" face="Arial Black, Gadget, sans-serif">学生信息收集系统</font></h1>
<form id="form1" name="form1" method="post" action="dealwith.php">
    <table align="center">
    <tr>
        <td>学籍号:</td>
        <td><input  type="text" name="tb_user"/></td>
    </tr>
    <tr>
        <td>密 码:</td>
        <td><input  type="password" name="tb_passWord"/></td>
    </tr>
    <tr align="center">
      <td colspan="2"  align="center"bgcolor="#FFCCFF" align="right"><input type="submit" name="subbutton" value="提交"  οnclick="return check_form();"/>
     <input type="reset" name="subbutton2" value="重置" /></td>
      </tr>
    </table>
</form>
</center>
</body>

</html>

dealwith.php文件内容

<!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_chinese_ci" />
<title>学生信息收集系统</title>
</head>
<?php
    $host="127.0.0.1";
    $userName="root";
    $passWord="root";
    $dbName="db_student";
    $connID=mysqli_connect("$host","$userName","$passWord");
    if(mysqli_select_db($connID,$dbName)){
        echo "数据库选择成功";
        }
    else{
        echo "数据选择失败";
        }
    if($_POST[subbutton]=="提交"){
    $stuId=$_POST[tb_user];
    $pasWo=$_POST[tb_passWord];
    $sql=mysqli_query("select * from stuquestion where stuId ='$stuId'");
    $info=mysqli_fetch_object($sql);
    if($info){
        if($pasWo==$info->pasWo){
            echo "<script language='javascript'> alert('登陆成功!');</script>";
            header('Location: answer.php');
            }else{
            echo "<script language='javascript'> alert('密码错误!');</script>";
            header('Location: Index.php');
                }
        }
else{
        echo "<script language='javascript'> alert('学籍号错误!');</script>";
        header('Location: Index.php');
        }
    }
    if($_POST[subbutton1]=="提交"){
        $answer=$_POST[answer1];
        date_default_timezone_set("PRC");
        $sql1=mysqli_query("update stuquestion set queAn='$answer',timNo='date('Y-m-d H:i:s')' where stuId='$stuId'");
        if($sql1){
            echo "<script> alert('提交成功!');</script>";
            header('Location: Index.php');
            }
            else{
                echo "<script> alert('提交失败!');</script>";
            header('Location: answer.php');
                }
        }
?>
<body>
</body>
</html>


评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值