PHP

Lourens

Well-Known Member
Joined
Jun 18, 2004
Messages
450
Hi,

I need some help here - my head is not quite with me as the flu is getting to me and I can not remember why the code like this does not work .

Code:
<?
if(($_login == "Login")&&($admin_pass == $admin_password)){
//What ever!
}
?>

but the following does

Code:
<?
if(($_REQUEST["login"] == "Login")&&($_REQUEST["admin_pass"] == $admin_password)){
//What ever!
}
?>
 

James

Expert Member
Joined
May 26, 2004
Messages
2,617
Firstly, if you are expecting a POST use $_POST and if you are expecting a GET use $_GET, it is just better policy and much safer.

Secondly, $_ refers to a protected variable and should be used as such. If you are just using it as a standard variable use $login instead.

This should work for you

Code:
<?php

$login = $_REQUEST["login"];
$admin_pass = $_REQUEST["admin_pass"];

if ($login == "Login" && $admin_pass == $admin_password)
{
          //What ever!
}
 

rorz0r

Executive Member
Joined
Feb 10, 2006
Messages
7,968
Not sure about the underscore but php has a feature called register_globals which would make your get/post inputs into actual variables ie like $login instead of $_POST["login"] etc.
 
Top