Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jan 2006
    Posts
    73
    Thanks
    2
    Thanked 3 Times in 3 Posts

    Undefined strings

    I have pages in a CMS I am developing that are similar to this line:

    PHP Code:
    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?

  • #2
    New Coder
    Join Date
    Mar 2009
    Location
    Chicago, IL
    Posts
    69
    Thanks
    0
    Thanked 15 Times in 15 Posts
    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:
    PHP Code:
    $msg $_POST['msg']; 
    If it is included in URL, you can get it using $_GET array:
    PHP Code:
    $msg $_GET['msg']; 

  • #3
    New Coder
    Join Date
    Jan 2006
    Posts
    73
    Thanks
    2
    Thanked 3 Times in 3 Posts
    Ya, strangely, even with register_globals on it still won't work. I guess that'll have to do for now.

  • #4
    New Coder
    Join Date
    Mar 2009
    Location
    Chicago, IL
    Posts
    69
    Thanks
    0
    Thanked 15 Times in 15 Posts
    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.

  • #5
    New Coder
    Join Date
    Jan 2006
    Posts
    73
    Thanks
    2
    Thanked 3 Times in 3 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •