我想将从复选框中选择的数据插入数据库以及用户在文本框中键入的文本。我希望复选框值和文本都进入我数据库的同一行。
我的abc.php代码:
<div class="container">
<h2>Please select the answer below:</h2>
<form>
<div class="checkbox">
<label><input type="checkbox" name="response" value="A">A</label>
</div>
<div class="checkbox">
<label><input type="checkbox" name="response" value="B">B</label>
</div>
<div class="checkbox">
<label><input type="checkbox" name="response" value="C">C</label>
</div>
<form method="post" name="input" action="insert.php" >
Question ID: <input name="questionid" type="text"/><br/>
<input type="submit" name="Submit" value="insert" />
</form>
我的insert.php代码
if(isset($_POST["response"]))
{
$query = "INSERT INTO response (student_id, response, question_id) VALUES (:studentID, :response, :questionid)";
$statement = $conn->prepare($query);
$statement->execute(
array(
':response' => $_POST["response"],
':studentID' => $_SESSION['studentid'],
':questionid' => $_POST["questionid"]
)
);
}
当我按下插入按钮时,没有任何反应.....有人可以帮忙吗?