954,597 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

PHP QUIZ

can somebody help me in dealing with this project...
I am making a quiz that a user can input their own set of questions..after doing a quiz other users can take it..and I don't know how to check if the user answers were right..
can you please help me? thanks!

Here's my code in getting the users answer to questions..

<html>
<head>

</head>
		
	<body>
	<form id="form1" name="form1" method="post" action="engquiz4.php">
  <table width="500" border="0">
    <tr>
      <td colspan="500"><b>Multiple Choice</b></td>
    </tr>
    <tr>
      <td colspan="500"><b>Choose the correct answer and press the "submit" when done.</b></td>
    </tr>
</table>
<?php
$connect = mysql_connect("localhost","garry","perez")or die("can't access database");
mysql_select_db("phplogin") or die("can't access database");

$SQL="SELECT* FROM engquiz WHERE quiznum=1";
$result=mysql_query($SQL);
$group1 = "1";

	while($row=mysql_fetch_assoc($result))
		{
    	echo $group1.". ".$row['question']."";
		echo "<input type= \"radio\" name =\"$group1\" value=\"q1o1\">".$row['opt1']."";
		echo "<input type= \"radio\" name =\"$group1\" value=\"q1o2\">".$row['opt2']."";
		echo "<input type= \"radio\" name =\"$group1\" value=\"q1o3\">".$row['opt3']."";
		$group1 ++;
		
		}
	?>
<p>
    <label>
    <input type="submit" name="Submit" value="Submit" />
    </label>
  </p>
  </form>
</body>
</html>
akocnin18
Newbie Poster
1 post since Nov 2011
Reputation Points: 10
Solved Threads: 0
 

check the data from the form against the 'correct value' in your DB. If you haven't got a cluse what I'm talking about, read up on $_POST variables and MySQL statements.

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,796 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: