Forum Moderators: coopster
<?php
include('database_access_param.php');
if(($qnumber=="")¦¦($qnumber==0))
{
$qnumber=1;
}
else
{
$qnumber=$qnumber+1;
}
$acount=0;
$answers = array();
$question="";
$answerblock=array();
$rightanswer=array();
$db_link=mysql_connect($hostname, $dbuser, $dbpassword) or die("Unable to connect to the server!");
mysql_select_db($dbname) or die("Unable to connect to the database.");
$sql = "select * from questions where qnumber=".$qnumber ;
print('<html>');
print('<head><title>');
print('Quiz 1</title>');
print('<link rel="stylesheet" href="report.css">');
print("</head>");
print('<body>');
print('<form name="form1" method="post" action="go2.php">');
print('<table class="report" align=left width=100%>');
print('<tr><th align=left colspan=2>Quiz</th></tr>');
print('<tr><td> </td></tr>');
$result=mysql_query($sql);
//;
if(mysql_numrows($result))
{
$row = mysql_fetch_row($result);
{
//print('<tr><td>'.$result2.'</td></tr>');
//$i=0;
//for($i=0; $i<20 ; $i++)
//{
$qid=1;
$sqln = "select * from questions where qid=".$qid ;
$z=0;
for($z=0;$z<100;$z++){
$sqln = "select * from questions where qid=".$qid ;
$qid=$qid+1;
$result2=mysql_query($sqln);
//;
if(mysql_numrows($result2))
{
$row = mysql_fetch_row($result2);
{
//$qid=$row[0];
$question=$row[1];
$answers[0]=$row[2];
$answers[1]=$row[3];
$answers[2]=$row[4];
$answers[3]=$row[5];
$answers[4]=$row[5];
$qnumber=$row[6];
$rightanswer=$row[2];
srand((float) microtime() * 10000000);
$rand_keys = array_rand($answers, 5);
$answer0=$answers[$rand_keys[0]] ;
$answer1=$answers[$rand_keys[1]] ;
$answer2=$answers[$rand_keys[2]] ;
$answer3=$answers[$rand_keys[3]] ;
$answer4=$answers[$rand_keys[4]] ;
print('<tr><td>'.$qnumber.')<input type="radio" name="answer['.$z.']" value="'.$answer0.'"><input type="radio" name="answer['.$z.']" value="'.$answer1 .'"><input type="radio" name="answer['.$z.']" value="'.$answer2.'"><input type="radio" name="answer['.$z.']" value="'.$answer3 .'"><input type="radio" name="answer['.$z.']" value="'.$answer4 .'"></td></tr>');
$qcount=$qcount+1;
if($rightanswer == $answer){
$acount=$acount + 1;
}
//else
}
//}
//end of for....
}
}
//print('<tr><td> <input type=hidden name=rightanswer value="'.$rightanswer.'"><input type= hidden name=qnumber value="'.$qnumber.'"></tr>');
}
print('<tr><td colspan=2><input type=submit name=submit value="Submit" >      <input type=reset name=reset value="Clear" ></td></tr></table>');
print('<p>You cannot go back and resubmit an answer. System counts every submit and it affects your score</p>');
}
else
{
//print('<input type =hidden name=score value="'.$score.'">');
//print('<tr><td colspan=2align=center><input type=submit name=submit value="Grade" ></td></tr></table>');
//print('</form>');
}
print('</body>');
print('</html>');
?>
One way to view what is being submitted by the form is to dump the superglobal of the action of the form. For example, you are using:
<form name="form1" method="post" action="go2.php">
<?php
print '<pre>';
print_r($_POST);
print '</pre>';
exit;
?>
Variables from outside PHP [php.net]
PHP and HTML [php.net]