Copy link to clipboard
Copied
Im trying to pass a variable from one page to the next, but it is not working correctly. the variable $message is set on the previous page and sent through the url to the next page, but my script bellow is not picking it up for some reason. Any help is appreciated.
<?php
if ($message == "pm") {
echo "Your passwords do not match each other. Please fix this and retry.";
} else if ($message == "pl") {
echo "Your password does not meet the required length. It must be between 6 and 16 characters in length";
} else if ($message == "ul") {
echo "Your Username doese not meet the required length. It must be between 5 and 30 characters in length";
} else if ($message == "ue") {
echo "That username exists. Please try another";
} else {
echo "";
}
?>
redirect from previous page: register.php?message=$warning
When it goes through the redirection it shows up as this in the browser "register.php?message=pm", "register.php?message=pl", "register.php?message=ul", or "register.php?message=ue", but my script above is not picking up that variable for some reason.
Copy link to clipboard
Copied
Please show us the part of the script that is assigning data passed from the form to the local $message variable on this page. Or did you forget that part?
Copy link to clipboard
Copied
jj12689 wrote:
Im trying to pass a variable from one page to the next, but it is not working correctly. the variable $message is set on the previous page and sent through the url to the next page, but my script bellow is not picking it up for some reason.
It's not picking it up because you're relying on a feature of PHP that was officially abandoned way back in 2002. The PHP configuration directive, register_globals, was turned off for security reasons, but a lot of hosting companies turned it back on to avoid breaking scripts. Thankfully, most hosting companies have abandoned that practice these days.
The solution is simple. Instead of using $message to get a value passed through the query string on the end of a URL, you need to use $_GET['message']. To get the value of a form variable, you use the $_POST superglobal array, e.g., $_POST['message'].
Change each instance of $message in your script like this:
if ($_GET['message'] == "pm") {
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more