0

I have a wamp server in green. PHP code found but $HTTP_GET_VARS and $_GET no found.

The page have this URL:

http://localhost/workfis/login.php?errorUsuario=vacio

The page have this code:

$variable1=$_GET['errorUsuario']=="vacio";
echo $variable1;
$variable2=$HTTP_GET_VARS['errorUsuario']=="vacio";
echo $variable2;

variable1 and variable2 dont print.

  • 2
    `==` is a comparison and is assigning `true` or `false`. If it doesn't print then it is `false`. – AbraCadaver May 08 '18 at 17:35
  • Turn on PHP error reporting. See https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display – Tiffany May 08 '18 at 19:31

1 Answers1

1

It looks like you're trying to assign the variable and compare it in the same statement. It will help to separate the two statements like so:

if(isset($_GET["errorUsuario"])){  // ensures value is set

    $variable1=$_GET['errorUsuario'];  // use = to assign a value

    if ($variable1 == "vacio"){       // use == to compare two values (returns true or false)
        echo $variable1;  // this will only print if the value is "vacio"
    }
}
  • Thnx for your answer. You have the reason for this question. Now, My problem is when I use this: $variable1=$_GET['errorUsuario']; echo $variable1; // This dont print. $variable2=$HTTP_GET_VARS['errorUsuario']; echo $variable2; // This dont print. – Carlos Terán May 08 '18 at 18:10
  • Can you post more of your PHP code then? The problem may be more evident if I can see more of how you are implementing this code. Thanks. – Brad Colacino May 08 '18 at 19:20
  • I solved it. The $HTTP_GET_VARS was the problem. Only found with $_GET. – Carlos Terán May 08 '18 at 20:32