![]() |
PHP - quiz - why is my code not working?
Hello,
I am writing a quiz for a Harry Potter role playing site i belong to. I figured that if i made a verriable called score and add 1 to it for each correct answer it would work, but for some reason it is not. Here is my code: :
- I have also tryed taking out the PHP and puting it in its own file and using the form action as that file. - I have also tryd making the button action the php file. -I have tryed making it $score=score++ , $score+1, and $score++ none of these have worked, I know this should be simple to pull off but i can not figure it out. |
how about this ? -
:
read some PHP tutorials FIRST ... ask questions later. and i think : <input name="question1" value="a" type="radio"> should be <input name="question1[]" value="a" type="radio"> but i;m not sure |
You should probably have the score checking in a PHP script which your quiz form submits to. And in that score checking script, you should be checking $_GET['question1'] or $_POST['question1'], depending on your form submission method.
example form page: :
<form action="grade.php" method="POST">example score script: :
<?php |
Quote:
thanks for the help both of you i apreciate it greatly |
Are you ever going back to the page and the score getting reset? is that what you are trying to handle? If you are then you need to create a hidden post value of their score and when you reload the page, you have to put it in.
|
I did a quiz like this on Latin nouns once. I'll go downstairs and try and find the DVD with it on and then you can have a look at that if you want.
|
thanks a lot matt. I got it to work though DR.p's sugestion worked. i should have posted that but thanks for offering ^_^
|
OK. If you need any more help just say...
|
| All times are GMT -5. The time now is 11:26 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC