<form method = "POST" name = "subjects" action ="createquestions.php">
Select Subject: <select name = "subjects">
<option value="English">English</option>
<option value="Math">Math</option>
<option value="Science">Science</option>
<option value="Filipino">Filipino</option>
</select> <br>
Multiple Choice: <input type = "text" name="MC"><br>
<input type = "submit" name = "confirm" value = "Confirm">
<a href = "home.php"><span>Cancel</span></a></center>
</form>
<?php
if(isset($_POST['confirm'])){
$MC = $_POST['MC'];
echo "<form method = 'POST' name = 'items' actions ='createquestions.php'>";
$items = 1;
echo "</form>";
for ($x = 1; $x <= $MC; $x++) {
echo "<form metod = 'POST' action = 'createquestions.php'>";
echo "Question Number $items:"; echo "<input type = 'text' name = 'questions' style='width: 500px'><br><br>";
echo "A. "; echo "<input type = 'text' name = 'ans1'>";
echo "B. "; echo "<input type = 'text' name = 'ans2'><br>";
echo "C. "; echo "<input type = 'text' name = 'ans3'>";
echo "D. "; echo "<input type = 'text' name = 'ans4'><br>";
echo "Correct Answer: "; echo "<input type = 'text' name ='cans'><br><br>";
$items++;
echo "</form>";
}
echo "<form method = 'POST' action = 'createquestions.php'>";
echo "<input type ='submit' name = 'save' value = 'Save'>";
echo "</form>";
}
?>
<?php
if(isset($_POST['save'])){
$user_id = $_SESSION['id'];
$questions = $_POST['questions'];
$ans1 = $_POST['ans1'];
$ans2 = $_POST['ans2'];
$ans3 = $_POST['ans3'];
$ans4 = $_POST['ans4'];
$cans = $_POST['cans'];
require_once('xcon.php');
$query = "INSERT INTO mcq (mc_id, mc_num, user_id, questions, ans1, ans2, ans3, ans4, cans)
VALUES ('NULL','$items','$user_id','$questions','$ans1','$ans2','$ans3','$ans4','$cans')";
$result = mysql_query($query);
if($result){
echo 'Insert Success!';
}
else{
echo 'Error';
}
}
?>
I am so sorry for posting the screenshot.. actually, those codes are all in one form and this is the full code that i have