(PHP) If statement stupidity -


this code checks if pin correct or not. code login/index page.

<!doctype html> <html>     <h1>         project_01     </h1>     <h2>         please enter access pin.     </h2>     <form action="checker.php" method="get">         <input type="text" name="pin"/>         <input type="submit" value="submit">     </form> </html> 

which works fine. code check if pin right turns blank page.

<!doctype html> <html>     <p>         <?php             $enc = $get_["pin"];          if($enc == "7885") {             echo ("user login.");         elseif($enc == "5296"):             echo ("admin login");         else:             echo ("error.");         }         ?>     </p> </html> 

either prints out rest of code, or of if statements return true. why happen , how fix it?

this accidental typo, should changed from

$enc = $get_["pin"]; 

to

$enc = $_get["pin"]; 

also, better formatting brackets:

<?php $enc = $_get["pin"];  if($enc == "7885") {     echo "user login."; } elseif ($enc == "5296") {     echo "admin login"; } else {     echo "error."; } 

Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -