
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.