Hello,
I'm trying to create a short quiz that basically has 1 question per screen and uses radio buttons for the answer choices.
I would like for the user to be able to make their answer selection and once the radio button is clicked their chosen answer value, as well as other data I'm collecting is inserted into the database.
However, I'm having trouble getting this to work properly. (I would prefer not to use a submit button on the page)
<form method="POST" action="<?php $php_self; ?> Question: True/False - The sky is blue</br> <input type='radio ' value='yes' id='answer' name='answer' onclick='correct_response();this.form.submit();document.location.href=\"next_question"\'> Yes</br> <input type='radio ' value='no' id='answer' name='answer' onclick='correct_response();document.location.href=\"next_question"\'>No</br> </form>
Here is what I'm hoping to do to insert the data into the database:
<?php if(isset($_POST['radio'])){ $answer = $_POST['answer']; $sql = "INSERT INTO user_answers('id', 'answer', 'question', 'date_created', 'date_modified')VALUES('NULL','$answer','date();', 'date();') mysql_query($sql); } ?>