我正在使用 PHP/MYSQL 创建一个包含单选按钮的表单。我正在尝试将选中的单选按钮的值添加到数据库中的表中。目前我无法将任何内容添加到数据库中。该表称为评估。
QUESTION1.PHP
<?php
include 'core/init.php';
include 'includes/overall/overall_header.php';
protect_page();
include 'includes/menu.php';
include 'includes/overall/navigate.php';
include 'includes/widgets/loggedin.php';
?>
<h1>Assessment</h1>
<form action="save.php" method="post">
<p class="p1">
Question 1</p>
<p class="p4">
Are you tall or short?</p>
<p class="p3">
<input type="radio" name="q1" value="1" />
1
<input type="radio" name="q1" value="2" />
2
<input type="radio" name="q1" value="3" />
3
<input type="radio" name="q1" value="4" />
4
<input type="radio" name="q1" value="5" />
5
</p><br><br>
</form>
<img src="Images/image1.png" alt="Submit" class="thumbnail" align="right" width="58" height="52" id="question2">
<img src="Images/save.png" alt="Submit" class="thumbnail" align="right" width="65" height="52">
<?php
}
include 'includes/overall/overall_footer.php';
?>
保存.PHP
<?php
session_start();
include('connection.php');
$q1=$_POST['q1'];
mysql_query("INSERT INTO `assessment` (q1) VALUES ('$q1')");
header("location: question2.php?");
mysql_close($con);
?>