问题:
想做个简易的答题系统,遇到点困难,就是提交不了,请大家帮帮忙,谢谢~!
<meta><title>问答</title>
验证页面
<?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>";
}
?>
解决方法:
使用官方Model Context Protocol PHP SDK将PHP应用程序功能暴露为MCP工具、资源和提示,用于代理工作流。
你的表单写错了
<meta><title>问答</title>
<?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>";
}
?>
php免费学习视频:立即使用
踏上前端学习之旅,开启通往精通之路!从前端基础到项目实战,循序渐进,一步一个脚印,迈向巅峰!










