I want to insert data selected from check boxes into a database as well as text which the user types into a text box. I want both the check box values and the text to go into the same row on my database.
My code for 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>
my code for 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"]
)
);
}
When i press the insert button, nothing happens..... can anyone help?
Aucun commentaire:
Enregistrer un commentaire