Let's say i have a script for a quiz or test or whatever, and to find out your score the page you end up going to is test.php?q=a&a=0,2,3,1,0 where the numbers represent the answers to the questions asked. How would I make it so that if i used $_GET["a"] it would at each number individually and check the answers to see if they were rite. I know I could have all the correct answers be 0 but that would make it easier to cheat on and I don't want that. So let's say the correct answers are 0,3,3,2,0 so when it checks it sees the first one is correct and moves on, then the script sees the second answer is wrong so if prints the correct answer...understand what i'm trying to do?I assume you answer the questions by filling in forms? If so, then just specify a different name for each text box(or whatever your using).
Say you have two text boxes, named box1 and box2.
The correct answer to box1 = 2, box2 = 1.
<?php
if ($_GET["box1"] = 2) {
echo ("Correct answer");
}
else {
echo ("Wrong answer, the answer is: 2");
}
if ($_GET["box2"] = 1) {
echo ("Correct answer");
}
else {
echo ("Wrong answer, the answer is: 1");
}
?>
Is that what your trying to use? Or something like it? I think this should work, I'm too lazy to type up a script and upload it to my host and everything to test it out .if the questions are from a form then each question will have it's own variable so hwo do yo uplan on gettin git like
test.php?q=a&a=0,2,3,1,0
"a" will only = 1 variable, not 5 of them. unless you have them al in 1 question.
your best bet is what Daerus said. also make it as a POST and not a GET for the forms action
Say you have two text boxes, named box1 and box2.
The correct answer to box1 = 2, box2 = 1.
<?php
if ($_GET["box1"] = 2) {
echo ("Correct answer");
}
else {
echo ("Wrong answer, the answer is: 2");
}
if ($_GET["box2"] = 1) {
echo ("Correct answer");
}
else {
echo ("Wrong answer, the answer is: 1");
}
?>
Is that what your trying to use? Or something like it? I think this should work, I'm too lazy to type up a script and upload it to my host and everything to test it out .if the questions are from a form then each question will have it's own variable so hwo do yo uplan on gettin git like
test.php?q=a&a=0,2,3,1,0
"a" will only = 1 variable, not 5 of them. unless you have them al in 1 question.
your best bet is what Daerus said. also make it as a POST and not a GET for the forms action