问题:
想做个简易的答题系统,遇到点困难,就是提交不了,请大家帮帮忙,谢谢~!
<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>";
}
?>
