Any student who wants to take this test follows the following steps
1. he/she registered him/her self.
2.secondly he enters his user name & password in a login form,if these entries are valid another form appears ,prompting him to enter his complete information.
3.after submitting data (I've implemented all validation checks on all forms)
4.a page appears with a question following options ,a user can select any one or can skip by simply clicking on next button,so another question appears,all these questions are retrieved from sql server table randomly.Ofcourse it was a difficult job,but thanks to God that we have achieved our goal.The only problem i'm facing now is setting time for a student ,because a student is given 30 minuts to take the test.
for this purpose we used time() of php ,but the results was not satisfactory,as in php
time() returns time in second & calculation was not easy,then we used date("h:i:s");
But the result was "cache limiter" error.Now tell me how to overcome this problem
i'm sending script attached with this mail .
Also tell me if any changes are needed to make in php.ini files.
THANKS
here is my script! ------------------------
<?php session_start(); session_register("count1"); session_register("op"); //$count1=50;
$con=mssql_connect("localhost/computername","username","password");
$db=mssql_select_db("Entry_Test",$con);
//generating random questions ids
// seed with microseconds
function make_seed() {
list($usec, $sec) = explode(' ', microtime()*2);
return (float) $sec + ((float) $usec * mt_rand());
}
$j=0;
$n=0;
$i=0;
//Sir,i need time check here
while($n<5)
{
mt_srand(make_seed());
$rn=mt_rand(1,20);
$ar[$j]=$rn;
$s=0;
for($k=0;$k<$n;$k++)
{
if($rn==$ar[$k])
$s=1;
}
if($s==0)
{
//retrieveing question from data base
$sql=mssql_query("select question,option1,option2,option3,correct_ans from questions where q_id='$ar[$n]'",$con);
while($rec=mssql_fetch_array($sql))
{
$q="$rec[0]";
$op1="$rec[1]";
$op2="$rec[2]";
$op3="$rec[3]";
$op4="$rec[4]";
$i++;
}
$n=$n+1;
$j++;
}//end of if
//sir,time must be checked here again(i.e each time when user clicks next(submit) button) so with in specified time user is shown questions
}//end of while
echo("<center><table border=0>");
echo("<form >");
echo("<tr ><td background=q1.png height=150 width=500 >"); echo("<h3><br><center>$q</h3></td></tr>"); echo("<p><center><tr><td ><img src=o1.png ></td></tr>"); echo("<tr><td><input type=radio name=r1 value=$op1>".$op1); echo("</td></tr>"); echo("<tr><td><input type=radio name=r1 value=$op2>".$op2); echo("</td></tr>"); echo("<tr><td><input type=radio name=r1 value=$op3>".$op3); echo("</td></tr></table></center><br><input type=image src=next_up.png>"); echo("</form>"); echo("$r1<br>$op<br>");
if(empty($r1)) $count1=$count1+0; else if($r1==$op) $count1=$count1+5; else $count1=$count1-5; $x=$count1; echo("you have got $x Marks<br>"); $op=$op4; ?> <html> <body bgcolor="#f0f4ff"> </body> </html> <a href="p1.html">show results</a>
_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php