Jump to content

[SOLVED] help with an IF Statement


acctman

Recommended Posts

Hi I need help cleaning up this coding. Is the "elseif" in the middle proper? It's looking to see if the username is admin and if so process the admin and pass if not then its a regular user and just send the Username

 

if ($user_name == admin) {
$password = "1234";
    if(isset($_GET["user_name"])) $user_name = $_GET["user_name"];
	if(isset($_GET["password"])) $password = $_GET["password"];
}
elseif ($user_name != admin) {
    
    if(isset($_GET["user_name"])) $user_name = $_GET["user_name"];
    else $isLoginValid = false;
}

Link to comment
https://forums.phpfreaks.com/topic/64934-solved-help-with-an-if-statement/
Share on other sites

no it's not working it seems to be skipping over the first set of IF statments and going to the bottom one. if i remove the $user_name == admin for the first IF statement set everything runs fine, same with the bottom. it doesn't seem to be checking the $user_name. its suppose to run the stuff underneath if user is ADMIN and if not then run the other stuff.

if ($user_name == admin) {

    if(isset($_GET["user_name"])) $user_name = $_GET["user_name"];
    else $isLoginValid = false;
    
    if(isset($_GET["password"])) $password = $_GET["password"];
    else $isLoginValid = false;
}
elseif ($user_name != admin) {
    
    if(isset($_GET["user_name"])) $user_name = $_GET["user_name"];
    else $isLoginValid = false;
}

this method seems to be working fine, less coding and no errors so far.

 

   if(isset($_GET["user_name"])) $user_name = $_GET["user_name"];
   else $isLoginValid = false;
    
   if($user_name == 'admin') {

 if(isset($_GET["password"])) $password = $_GET["password"];
 else $isLoginValid = false;

} 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.