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
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;
}

Link to comment
Share on other sites

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;

} 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.