Every Thing is working fine for my online quiz system but page of uploading questions is not working as it should be working.
The user is restricted to add 20 questions at a time if the limit exceeds, a message will prompted and he will be redirected to his account.
This is the form which will allow the user to input his question, four options and a correct option.
<html>
<body>
<form action="be_uploadquiz.php" method="post">
<table><tr><td>Enter Question Here</td>
<td>
<input name="question" type="text" maxlength="100" /></td></tr>
<tr><td>Enter First Option</td>
<td>
<input name="opt1" type="text" maxlength="100" /></td></tr>
<tr><td>Enter Second Option</td><td>
<input name="opt2" type="text" maxlength="100" /></td></tr>
<tr><td>Enter Third Option</td>
<td>
<input name="opt3" type="text" maxlength="30" /></td></tr>
<tr><td>Enter Fourth Option</td>
<td>
<input name="opt4" type="text" maxlength="30" /></td></tr>
<tr><td>Select The Correct Option</td>
<td>
<select name="woptcode">
<option>A</option>
<option>B</option>
<option>C</option>
<option>D</option>
</select>
</td></tr>
<tr><td>
<input name="submit" type="submit" value="Next" />
</td></tr></table></form>
</body>
</html>
Here is the uploadquiz.php file which inserts the questions
<?php
session_start();
$link = mysql_connect("localhost","root","");
mysql_select_db("quiz",$link);
$question = $_POST['question'];
$opt1 = $_POST['opt1'];
$opt2 = $_POST['opt2'];
$opt3 = $_POST['opt3'];
$opt4 = $_POST['opt4'];
$woptcode = $_POST['woptcode'];
if ( isset( $_POST['submit'] ) ) {
$sql = "INSERT INTO be_quiz (question,opt1,opt2,opt3,opt4,woptcode) VALUES ('$question', '$opt1','$opt2','$opt3','$opt4','$woptcode')";
$i++;
header('Location:be_uploadquiz.html');
if($i==20)
{
header('Location:message.html');
}
}
session_destroy();
if(!mysql_query($sql))
{
die('Error:'.mysql_error());
}
mysql_close();
?>
I want the user to redirect again to uploadquiz.html if the limit is not reached and to a file message.html if the maximum limit (i.e 20 questions have been reached) is reached and then to his account. this is not working need help.