Page 1 of 1

Reading, writting and updating a text file.

Posted: Wed Jul 28, 2010 12:03 am
by parkie
Hi All, I have written a quiz and the name of the person completing is then emailed, what I would like to do is that an identification number is also sent with the name. What I'm thinking is using a text file to hold a number that number is called incremented and then emailed the incremented number then saved into the text file to be allocated the next time a person passes the quiz. I'm not really sure how to go about this any advise or help would be great. This is the code I am using to grade and email the current quiz questions.
Many Thanks.

$score++;
if($_POST['q43'] == 2)
$score++;
if($_POST['q44'] == 3)
$score++;
if($_POST['q45'] == 4)
$score++;


$score1 = $score /45 * 100; //makes score a percent.
}

if($score1 > 99 )//A score of over 99%//Person passes this drops into below

{ echo '<A HREF = "certsubmit.html"> Congratulations You Have Passed the Inductions. Click here to complete your certificate</A>';
echo "You will be provided with a safety booklet. Please read it, sign and return Declaration page to Head Office or Supervisor before starting work.";
// sends email with name and list of answers.
$to = "info@engineering.com";
$subject = " Induction";//email header
$message = "Results for " . $_POST['fname'] . ":\n";//contents of email
$message .= "\n";
$headers = "From: webmaster@zawebsites.com";


for ($i = 1; $i <= 28; $i++)//loops lists questions answered
{
if (isset($_POST['q' . $i]))
$message .= "Answer for question " . $i . ": " . $_POST['q' . $i] . "\n";//list questions
}
mail($to, $subject, $message, $headers);
}
else
echo "Please click the Browser Back Button and attempt the Assessment again";//Failed try again