PDA

View Full Version : Finding a correct answer script.



cheatpark
January 23rd, 2002, 13:56
At my school I have been asked to help make a sort of quiz thing with questions. Its for german. Basically when students use it they have to type in stuff to complete sentences and stuff. I need a script that checks if the answer is correct. I've been told to use excel but have ignored their advice and want to use php to program it. Also don't make a script that connects to a mysql database. I don't think my schools website supports php so keep it as simple as possible. Can someone help me?

megapuzik
January 23rd, 2002, 14:23
$answer1 = "banana";

if($form_field1 == $answer1)
print "ok";
else
print "bad answer";

cheatpark
January 23rd, 2002, 14:33
I got an error. Warning: Undefined variable: form_field1 in D:\hosting\usrv4283j\cheatpark.net\correct_answer.php on line 8

I created a form called $form_field1 and it still came up with the error.

megapuzik
January 23rd, 2002, 15:17
You should call the form -> form_field1 , not with the $
in html, you shouldnt use $.
but in php, to call the field you need to pass it like a var...
ok ?

cheatpark
January 23rd, 2002, 15:29
It works now. Thanks.

Cyber
January 23rd, 2002, 15:30
mega, it should be:




$answer1 = "banana";

if ($form_field1 == $answer1) {
print "ok";
} else {
print "bad answer";
}

megapuzik
January 23rd, 2002, 15:41
You dont need the { } becaouse its only 1 line....

cheatpark
January 23rd, 2002, 16:48
Its working fine with me without that extra thing added.

Dusty
January 23rd, 2002, 19:38
I don't think my schools website supports php so keep it as simple as possible.Question: If the server doesn't support PHP then I don't think no matter how simple the script is it would run... or did you mean to say "I don't think my schools website supports MySQL"?

cheatpark
January 30th, 2002, 14:46
When it says if the answer is right or wrong I want a picture to appear. I tried inserting html in but this did not work. Do I need to close the php tags?

Cyber
January 30th, 2002, 15:18
did u try:



echo '<img src="ghghgfgh">';


?

cheatpark
January 30th, 2002, 16:59
Whereabouts do I put that?

cheatpark
January 30th, 2002, 17:05
Its ok. Works now. This is what I done if anyone's interested. http://www.cheatpark.net/correct_answer.php