[Wolves] Replacing globals on with off php
Wayne Morris
waynelists at machx.co.uk
Tue Apr 5 18:04:13 UTC 2011
Got an old bit of php (a classified ads site ) which I like but used
'register globals on' and I understand this is not a good idea.
So can someone give me a starter for ten to get rid of the globals bit
(don't really understand how they worked anyway) eg in this snippit
which is for logon:
function verifyUser()
{
global $ADMIN_EMAIL;
session_start();
global $email, $passwd;
if( session_is_registered( "email" ) && session_is_registered(
"passwd" ) )
{
$result = mysql_query( "SELECT email, passwd FROM user
WHERE email='$email' AND BINARY passwd='$passwd'" ) or error( "Login
failed, please contact <a href=\"$ADMIN_EMAIL\">adminstrator</a>" );
if( mysql_num_rows( $result ) == 1 ) return true;
}
return false;
}
function verifyAdmin()
{
session_start();
global $ADMIN_NAME, $ADMIN_PASS, $adminPasswd, $adminName;
if( session_is_registered( "adminName" ) &&
session_is_registered( "adminPasswd" ) )
{
if( $adminName == $ADMIN_NAME && $adminPasswd == $ADMIN_PASS )
return true;
}
return false;
}
cheers
More information about the Wolves
mailing list