Posted by nice.guy.nige on 07/31/07 21:39
While the city slept, php.ajay@gmail.com (php.ajay@gmail.com) feverishly
typed...
> Hi
> I have a great problem. I have successfully completed
> ONLINE EXAM project.But Finally client asked "I want to include time
> for my site."O.K I tried But every time when i click on next question
> time is also refreshed and it comes from starting time.Please help
> me.VERY URGENT
> Thank u
Assuming as other posters have said that this is a form with a question, and
then onto the next page... maybe something like;
q1.php
=====
<form name="quiz1" action="q2.php" method="post">
<input type="hidden" value="<? echo time(); ?>" name="startTime">
What colour is blue? <input type="text" name="q1">
<input type="submit">
</form>
q2.php
=====
<?
if($_POST["q1"] == "blue") {
$score = 1;
}
else {
$score = 0;
}
?>
<form name="quiz2" action="q3.php" method="post">
<input type="hidden" value="<? echo $_POST["startTime"]; ?>"
name="startTime">
<input type="hidden" value="<? echo $score; ?>" name="score">
How many eggs in a dozen? <input type="text" name="q2">
<input type="submit">
</form>
.... etc...
end.php
======
<?
$startTime = $_POST["startTime"];
$endTime = time();
$totalTime = $endTime - $startTime;
$score = $_POST["score"];
?>
<p>Your score was <? echo $score; ?> and you took <? echo $totalTime; ?> to
complete the quiz</p>
.... This is all off the top of my head and not tested in anyway shape or
form, but it may at least give you some ideas to work on.
Hope that helps,
Nige
--
Nigel Moss http://www.nigenet.org.uk
Mail address will bounce. nigel@DOG.nigenet.org.uk | Take the DOG. out!
"Your mother ate my dog!", "Not all of him!"
[Back to original message]
|