欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

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

程序员文章站 2022-04-23 14:43:15
...
想做个简易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>";
}
?>

------解决方案--------------------
你的表单写错了

<form name="t" mothod="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="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 />

以上就是对念做个简易php选择题答题系统的全部介绍,如果您想了解更多有关php编程入门,请关注PHP中文网。