Welcome, Guest
  • Author Topic: upgrading scripts to new PHP  (Read 3500 times)

    Musicman

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 2685
      • View Profile
      • Email
    upgrading scripts to new PHP
    « on: 12/21/02, 05:06 »
    Hi,

    as you may know, new PHP (4.1 and later) does no longer make all incoming vriables global, as a security enhancements.
    Now, this code snippet should help since it does the work and at the same time documents which vars are expected:
    // variables that might come in via querystring
    $get_vars = array("action");
    // variables that might come in via post
    $post_vars = array("user", "password", "email");
    // the actual code
    foreach ($get_vars as $v)
     if(isset($_GET[$v]))
       $$v = $_GET[$v];
    foreach($post_vars as $v)
     if(isset($_POST[$v]))
       $$v = $_POST[$v];

    You still hve to identify those vars first, unless the script was nicely documented already :)

    Musicman