next up previous contents index
Next: Client's clocks are more Up: Measuring Time Previous: Blurry Images (PHP)   Contents   Index


Measuring Time with Submit Buttons (PHP)

Here is another example that measures time. In contrast to the previous one where participants clicked into the image itself here we use submit buttons.

<HTML>
<?
    $sec=explode(" ",microtime());
    $sec=$sec[0]+$sec[1];
    if (! $SEC)
        echo "<HEAD>
            <META HTTP-EQUIV=Refresh CONTENT=6;URL=$SCRIPT_NAME?SEC=$sec>
            </HEAD>";
    echo "<BODY BGCOLOR=white>
        <FORM METHOD=POST ACTION=$SCRIPT_NAME>\n";
    if (! $SEC) {
    echo "<CENTER><IMG SRC=123.gif></CENTER><BR>
        You have 6 seconds for the next question:<P>
        David Hume was born in?
        <INPUT TYPE=SUBMIT NAME=A VALUE=1711>
        <INPUT TYPE=SUBMIT NAME=A VALUE=1723>
        <INPUT TYPE=HIDDEN NAME=SEC VALUE=$sec>";
    }
    else {
        $diff = $sec-$SEC;
        echo "Answering took you $diff seconds.<BR>";
        switch ($A) {
          case 1711: echo "Correct. David Hume was born 7th May 1711.";break;
          case 1723: echo "Wrong. 1723 is the year when  Adam Smith was baptised.";break;
          default:   echo "You have been too slow...";
        }
    }
?>
</FORM>
</BODY>
</HTML>


next up previous contents index
Next: Client's clocks are more Up: Measuring Time Previous: Blurry Images (PHP)   Contents   Index
Oliver Kirchkamp