I'm having a problem with this. Let's say, I want to get a user's name in a simple form, the action being a new page that will use the name (newpage.php) and the method being "GET." <form action="newpage.php" method="get"> What is your name? <input type="text" name="Uname" maxlength="25" size="30" /><br /> <input type="submit" value="Customize" /> </form> Code (markup): Now, in newpage.php, we want to use their name in a greeting. This is what I tried: <?php $theirName = $_GET['Uname']; echo "Hello ".$theirName."!"; ?> Code (markup): This hasn't been working for me. However, what will work is if I simply use: <?php echo $Uname; ?> Code (markup): In the above example, I have not defined any variable by using the $_GET array, I simply am able to get the value by throwing a $ in front of it. Why won't it assign the value to the variable I specify? Why has it become a variable without any $_GET or actions on my part? I know I am a beginner, this confuses me. Anyone's help would be greatly appreciated!
What version of php are you using ? The only reason for registering superglobals is having register_globals in your ini, which is an incredibly bad idea and it can make it hard to program.....
I am using PHP 4.1.1 I believe to develop locally on my machine (it is what came with the PHPTriad installation) and my web server uses PHP5, but the same error occurred on both. I apologize, I am still learning, could you explain your response some more please? I am a C++ programmer who is learning PHP, and in many ways PHP is much easier, but in several ways it confuses me. I'm mostly learning by trial and error and reading other people's scripts.
"register_globals On" in php.ini means that all variables like $_POST['var1'], $_GET['var2'] are made variables in your script, like $var1, $var2 krackjoe is right, using that setting is very bad idea, you should set it off or update your php to latest (register_globals is off on php > 4.2) read this http://www.php.net/manual/en/security.globals.php