I'm trying to access my variable $score
from a different file but I keep getting an error message.
I've already tried adding global to it to make it a global variable and I've tried it without global.
My current code is below (not the whole files just a bit)
process.php file (lines 29 -34)
if($correct_choice == $selected_choice){
global $score;
$_SESSION['score']++;
$score = $score++;
}
final.php file (lines 36 - 30)
You are Done!
Congrats! You have completed the test
Final score:
Take Test AgainI want the score users received in their quiz to display on the screen, however right now the error I keep getting is
'Notice: Undefined variable: score in C:\xampp\htdocs\project\phpstaff\quiz\final.php on line 30
T'
Line 30 is <?php echo $score; ?>
In case you're wondering, I've already included <?php session_start(); ?>
to both files and $_SESSION['score']
seems to be working fine.