PHP Classes

register_globals

Recommend this page to a friend!

      Top level forums  >  PHP Specialists  >  General  >  register_globals  
Subject:register_globals
Summary:How do I remove dependence
Messages:2
Author:Lisa Warren
Date:2011-05-27 07:15:37
Update:2011-06-02 16:40:20
 

  1. register_globals   Reply   Report abuse  
Picture of Lisa Warren Lisa Warren - 2011-05-27 17:39:17
I am trying to learn php code and have run into an issue.

I have many scripts that have register_globals, but for security reasons and the mess it caused,I have shut it down.

Now I cannot get scripts to work and need to know if there is a way to get rid of register_globals in a script. I am trying to figure out what to put in place of word global. I am also trying to figure out how to change some code.

Here are a few examples:
$r = $_GET["r"];
$step = $_GET["step"];
if (!$id) { $id = $_GET["id"]; }
if (!$username) { $username = $_GET["username"]; }
if (!$password) { $password = $_GET["password"]; }
function userlogin() {
foreach (array_keys($GLOBALS) as $i) {if(!isset(${$i})) global ${$i};}

if (!$id && !$password) {
?>
Enter your login information.

and here is another from same script. I do not understand much php so I am lost on how to change the global.

$reset = 1;
function brotator($br_rid) {
global $url,$dbhost,$dbuser,$dbpass,$dbname;
$db = mysql_pconnect($dbhost, $dbuser, $dbpass) or die("Could not connect");

Here is one more from another script.

function pageHead() {
global $mena_head, $page, $fontface;
echo("<p><font face=$fontface size=4><b>$mena_head[$page]</b></font></p>");
}

I have these global throughout script.

Thank you for any help you can give me.

There is 1 reply in this thread, which is not being displayed.
Browsing this forum thread replies is available only to premium subscribers.


Go to the premium subscriptions page to learn how to become a premium subscriber and have full access to this forum.