View Full Version : Undefined strings

03-24-2009, 05:24 AM
I have pages in a CMS I am developing that are similar to this line:

if ($msg) echo "$msg<br><br>";

I had taken a long break from coding and come back and my content pages were no longer working. This is PHP version 5, and the string is not defined, and never was. However, before the way it worked was through the address bar like page.php?msg=Hi. I understand it would have to be defined as by the post or get methods but before it was working fine, any ideas?

03-24-2009, 05:43 AM
You probably had register_globals turned on. register_globals is huge security risk and was disabled by default since PHP 4.2.

If your form was submitted using POST, than you can get your value using $_POST array:

$msg = $_POST['msg'];

If it is included in URL, you can get it using $_GET array:

$msg = $_GET['msg'];

03-24-2009, 06:00 AM
Ya, strangely, even with register_globals on it still won't work. I guess that'll have to do for now. :(

03-24-2009, 06:13 AM
Try to avoid register_globals at any cost. It is deprecated from PHP 5.3 and will break your script on later versions of PHP.

03-24-2009, 06:27 AM
Nevermind, I was changing the value on the wrong php.ini. You are right, it doesn't work anymore. I'll just have to recode some previous work, thanks for the help.