时间:2021-07-01 10:21:17 帮助过:3人阅读
想做个简易的答题系统,遇到点困难,就是提交不了,请大家帮帮忙,谢谢~!
<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   <input type="radio" value="B"/>B.16 <br /> <input type="radio" value="C"/>C.16   <input type="radio" value="D"/>D.36 <br /> </form> <br /> <form name="t2" mothod="post" action=""> 2.兔子和乌龟比什么绝对不会输?<br /> <input type="radio" value="A"/>A.跳远   <input type="radio" value="B"/>B.跳高 <br /> <input type="radio" value="C"/>C.仰卧起坐   <input type="radio" value="D"/>D.赛跑 <br /> </form> <br /> <form name="t3" mothod="post" action=""> 3.小明妈妈:“小明赶紧切土豆去!”小明:“切,我不切!提问:小明要不要去切土豆?<br /> <input type="radio" value="A"/>A.切   <input type="radio" value="B"/>B.不切 <br /> <input type="radio" value="C"/>C.在犹豫   <input type="radio" value="D"/>D.不知道 <br /> </form> <br /> <form name="t4" mothod="post" action=""> 4.小明妈妈:“小明,去买瓶醋去!”小明:“我去,我不去!”提问:小明到底要不要去买醋?<br /> <input type="radio" value="A"/>A.去   <input type="radio" value="B"/>B.不去 <br /> <input type="radio" value="C"/>C.在犹豫   <input type="radio" value="D"/>D.妈妈去 <br /> </form> <br /> <form name="t5" mothod="post" action=""> 5.赛跑中,一名选手超过了第二名的选手,请问他现在是第几名<br /> <input type="radio" value="A"/>A.第一名   <input type="radio" value="B"/>B.第二名 <br /> <input type="radio" value="C"/>C.第三名   <input type="radio" value="D"/>D.第四名 <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   <input type="radio" name="t1" value="B"/>B.16 <br /> <input type="radio" name="t1" value="C"/>C.16   <input type="radio" name="t1" value="D"/>D.36 <br /> <br /> 2.兔子和乌龟比什么绝对不会输?<br /> <input type="radio" name="t2" value="A"/>A.跳远   <input type="radio" name="t2" value="B"/>B.跳高 <br /> <input type="radio" name="t2" value="C"/>C.仰卧起坐   <input type="radio" name="t2" value="D"/>D.赛跑 <br /> <br /> 3.小明妈妈:“小明赶紧切土豆去!”小明:“切,我不切!提问:小明要不要去切土豆?<br /> <input type="radio" name="t3" value="A"/>A.切   <input type="radio" name="t3" value="B"/>B.不切 <br /> <input type="radio" name="t3" value="C"/>C.在犹豫   <input type="radio" name="t3" value="D"/>D.不知道 <br /> <br /> 4.小明妈妈:“小明,去买瓶醋去!”小明:“我去,我不去!”提问:小明到底要不要去买醋?<br /> <input type="radio" name="t4" value="A"/>A.去   <input type="radio" name="t4" value="B"/>B.不去 <br /> <input type="radio" name="t4" value="C"/>C.在犹豫   <input type="radio" name="t4" value="D"/>D.妈妈去 <br /> <br /> 5.赛跑中,一名选手超过了第二名的选手,请问他现在是第几名<br /> <input type="radio" name="t5" value="A"/>A.第一名   <input type="radio" name="t5" value="B"/>B.第二名 <br /> <input type="radio" name="t5" value="C"/>C.第三名   <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>"; } ?>