Code: Select all
<?php
session_start();
include('colorquiz.php');
$choice=$_GET['choice'];
$right=@$_GET['right'];
$left=@$_GET['left'];
$which=$_GET['which'];
$correctright=$rightcolors[$choice];
$correctleft=$leftcolors[$choice];
if ($which=='right') {
if (metaphone($left) == metaphone($correctleft)) {
print("Correct! $correctleft is the capital of $correctright!");
print("<p><a href='colorquizask.php'>Play again </a>");
}
else {
print("Wrong Study More!<p>\n");
print("<a href='colorquizask.php'>Back to home </a><p>\n");
print("OR try again: What is opposite of $correctright on the color wheel?<br>");
print("<form action='colorquizcheck.php' method='get'>\n");
print("<input type='text' name='left'><br>\n");
print("<input type='hidden' name='right' value=$right>\n");
print("<input type='hidden' name='which' value=$which>\n");
print("<input type='hidden' name='choice' value=$choice>\n");
print("<input type='submit' value='Submit Answer'>");
print("</form>\n");
} }
else {
if (metaphone($right) == metaphone($correctright)) {
print("Correct! The color opposite of $correctright is $correctleft!");
$saywhich='false';
print("<p><a href='colorquizask.php'>Play again </a>");
}
else {
print("Wrong Study More!<p>\n");
print("<a href='colorquizask.php'>Back to home </a><p>\n");
print("OR try again: $correctleft is the opposite of what color?<br>");
print("<form action='colorquizcheck.php' method='get'>\n");
print("<input type='text' name='right'><br>\n");
print("<input type='hidden' name='left' value=$left>\n");
print("<input type='hidden' name='which' value=$which>\n");
print("<input type='hidden' name='choice' value=$choice>\n");
print("<input type='submit' value='Submit Answer'>");
print("</form>\n");
} }
if( isset($_SESSION['sumbit'])){
$_SESSION['submit'] = 1;
} else {
if($_SESSION['submit'] =>2){
header("colorquizask.php");
}
$_SESSION['submit'] += 1;
}
?>
As seen at the bottom I have it so it is at one and when it reaches 2 it will revert back to homepage. I am new to PHP and am still learning it and when looking at the documents on PHP sessions I was getting quite confused. I would appreciate any help.