I'm trying to get the user to enter their name into a text box, and then output it through each page (part of switch and case):
default:
$message = "Enter your name and click start.";
$nextDecision = "
<form action=\"index.php\" method=\"POST\">
<input type=\"text\" name=\"input_value\">
<input type=\"submit\" value=\"Start\" name=\"submit\" />
</form>";
if (isset($_POST['submit']))
{
// Execute this code if the submit button is pressed.
$name = $_POST['input_value'];
$message = "message";
$nextDecision = "<form action=\"index.php\" method=\"get\">
<input type=\"radio\" name=\"choice\" value=\"back\">choice<br>
<input type=\"submit\">
</form>";
}
break;
In my index.php page, it will print the name until the user presses submit and goes to a different case, outside of the if statement. Is there a way to pass the variable outside of the if statement?