Jump to content

[SOLVED] Else/if statements Help


twilitegxa

Recommended Posts

I have the following else/if statements:

 

$gender = (!empty($_POST['gender']))?$_POST['gender']:""; //Male or female?
$status = (!empty($_POST['status']))?$_POST['status']:""; //Hero or villain?

if($status == "villain"){
        //Since you're a villain, we just redirect here to the villain page
        header("Location: villain.php");
        exit;
}elseif($status == "hero"){
        if($gender == "male"){
                //You are a male hero!
                header("Location: knight.php");
        exit;
        }elseif($gender == "female"){
                //You are a female hero!
                header("Location: scout.php");
        exit;
        }

 

But I would like to add a couple more options to redirect the user:

 

I now want to give the user an option of a male or female villain, to redirect to fdark_warrior.php and mdark_warrior.php respectively. How do I adjust my if else statement?

Link to comment
Share on other sites

I got it, thanks for the help. Here's what I did, in case anyone wants to see:

 

$gender = (!empty($_POST['gender']))?$_POST['gender']:""; //Male or female?
$status = (!empty($_POST['status']))?$_POST['status']:""; //Hero or villain?

if($status == "villain"){
if($gender == "male") {
	//You are a male villain
	header("Location: mdark_warrior.php");
	exit;
	}elseif($gender == "female"){
	//You are a female villain
	header("Location: fdark_warrior.php");
	exit;
	}
}elseif($status == "hero"){
        if($gender == "male"){
                //You are a male hero!
                header("Location: knight.php");
        exit;
        }elseif($gender == "female"){
                //You are a female hero!
                header("Location: scout.php");
        exit;
        }
}

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.