您好,欢迎访问一九零五行业门户网

想做个简易php选择题答题系统

问题:
想做个简易的答题系统,遇到点困难,就是提交不了,请大家帮帮忙,谢谢~!
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>问答</title> </head> <body> <form name="t" mothod="post" action = "checktopic.php"> <form name="t1" mothod="post" action=""> 1.6匹马拉着一架大车跑了6公里,6匹马一共跑了多少公里?<br /> <input type="radio" value="a"/>a.6&nbsp;&nbsp;&nbsp <input type="radio" value="b"/>b.16&nbsp;&nbsp;<br /> <input type="radio" value="c"/>c.16&nbsp;&nbsp;&nbsp <input type="radio" value="d"/>d.36&nbsp;&nbsp;<br /> </form> <br /> <form name="t2" mothod="post" action=""> 2.兔子和乌龟比什么绝对不会输?<br /> <input type="radio" value="a"/>a.跳远&nbsp;&nbsp;&nbsp <input type="radio" value="b"/>b.跳高&nbsp;&nbsp;<br /> <input type="radio" value="c"/>c.仰卧起坐&nbsp;&nbsp;&nbsp <input type="radio" value="d"/>d.赛跑&nbsp;&nbsp;<br /> </form> <br /> <form name="t3" mothod="post" action=""> 3.小明妈妈:“小明赶紧切土豆去!”小明:“切,我不切!提问:小明要不要去切土豆?<br /> <input type="radio" value="a"/>a.切&nbsp;&nbsp;&nbsp <input type="radio" value="b"/>b.不切&nbsp;&nbsp;<br /> <input type="radio" value="c"/>c.在犹豫&nbsp;&nbsp;&nbsp <input type="radio" value="d"/>d.不知道&nbsp;&nbsp;<br /> </form> <br /> <form name="t4" mothod="post" action=""> 4.小明妈妈:“小明,去买瓶醋去!”小明:“我去,我不去!”提问:小明到底要不要去买醋?<br /> <input type="radio" value="a"/>a.去&nbsp;&nbsp;&nbsp <input type="radio" value="b"/>b.不去&nbsp;&nbsp;<br /> <input type="radio" value="c"/>c.在犹豫&nbsp;&nbsp;&nbsp <input type="radio" value="d"/>d.妈妈去&nbsp;&nbsp;<br /> </form> <br /> <form name="t5" mothod="post" action=""> 5.赛跑中,一名选手超过了第二名的选手,请问他现在是第几名<br /> <input type="radio" value="a"/>a.第一名&nbsp;&nbsp;&nbsp <input type="radio" value="b"/>b.第二名&nbsp;&nbsp;<br /> <input type="radio" value="c"/>c.第三名&nbsp;&nbsp;&nbsp <input type="radio" value="d"/>d.第四名&nbsp;&nbsp;<br /> </form> <br /> <input type = "submit" value = "提交"> <input type = "reset" value = "重置"> </form> </body> </html>
验证页面
<?php header('content-type:text/html;charset = utf-8'); include_once ('conn.php'); if($_post['t1']) { $t = 0; $t1 = $_post['t1']; $t2 = $_post['t2']; $t3 = $_post['t3']; $t4 = $_post['t4']; $t5 = $_post['t5']; if($t1 == 'c') { $t += 20; } if($t2 == 'd') { $t += 20; } if($t3 == 'b') { $t += 20; } if($t4 == 'c') { $t += 20; } if($t5 == 'b') { $t += 20; } } $sql = "update `information`.`user` set `sorce` = '$t' where `user`.`username` = '".$_cookie['user']."';"; mysql_query($sql); $num = mysql_affected_rows(); if($num>0) { echo "<script>alert('你的分数为:$t');location='index.php';</script>"; } else { echo "<script>alert('系统出错!');location='login.php';</script>"; } ?>
解决方法:
你的表单写错了
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>问答</title> </head> <body> <form name="t" method="post" action = "checktopic.php"> 1.6匹马拉着一架大车跑了6公里,6匹马一共跑了多少公里?<br /> <input type="radio" name="t1" value="a"/>a.6 &nbsp <input type="radio" name="t1" value="b"/>b.16 <br /> <input type="radio" name="t1" value="c"/>c.16 &nbsp <input type="radio" name="t1" value="d"/>d.36 <br /> <br /> 2.兔子和乌龟比什么绝对不会输?<br /> <input type="radio" name="t2" value="a"/>a.跳远 &nbsp <input type="radio" name="t2" value="b"/>b.跳高 <br /> <input type="radio" name="t2" value="c"/>c.仰卧起坐 &nbsp <input type="radio" name="t2" value="d"/>d.赛跑 <br /> <br /> 3.小明妈妈:“小明赶紧切土豆去!”小明:“切,我不切!提问:小明要不要去切土豆?<br /> <input type="radio" name="t3" value="a"/>a.切 &nbsp <input type="radio" name="t3" value="b"/>b.不切 <br /> <input type="radio" name="t3" value="c"/>c.在犹豫 &nbsp <input type="radio" name="t3" value="d"/>d.不知道 <br /> <br /> 4.小明妈妈:“小明,去买瓶醋去!”小明:“我去,我不去!”提问:小明到底要不要去买醋?<br /> <input type="radio" name="t4" value="a"/>a.去 &nbsp <input type="radio" name="t4" value="b"/>b.不去 <br /> <input type="radio" name="t4" value="c"/>c.在犹豫 &nbsp <input type="radio" name="t4" value="d"/>d.妈妈去 <br /> <br /> 5.赛跑中,一名选手超过了第二名的选手,请问他现在是第几名<br /> <input type="radio" name="t5" value="a"/>a.第一名 &nbsp <input type="radio" name="t5" value="b"/>b.第二名 <br /> <input type="radio" name="t5" value="c"/>c.第三名 &nbsp <input type="radio" name="t5" value="d"/>d.第四名 <br /> <br /> <input type = "submit" value = "提交"> <input type = "reset" value = "重置"> </form> </body> </html>
<?php header('content-type:text/html;charset = utf-8'); include_once ('conn.php'); $t = 0; $t1 = $_post['t1']; $t2 = $_post['t2']; $t3 = $_post['t3']; $t4 = $_post['t4']; $t5 = $_post['t5']; if($t1 == 'c') { $t += 20; } if($t2 == 'd') { $t += 20; } if($t3 == 'b') { $t += 20; } if($t4 == 'c') { $t += 20; } if($t5 == 'b') { $t += 20; } $sql = "update `information`.`user` set `sorce` = '$t' where `user`.`username` = '".$_cookie['user']."';"; mysql_query($sql); $num = mysql_affected_rows(); if($num>0) { echo "<script>alert('你的分数为:$t');location='index.php';</script>"; } else { echo "<script>alert('系统出错!');location='login.php';</script>"; } ?>
其它类似信息

推荐信息