Jump to content

multiple if/else statements


jhodara

Recommended Posts

Hi There,

 

Im trying to figure out how to do this if/else statement. I need it to say, "if this is true, do this. if this is true, do this. If neither is true, do this.

 

So there are three different possible outcomes. I tried to put each new if inside of the previous else. but that doesn't seem to work.

 

 

$firstname = $_REQUEST['firstname'];
$lastname = $_REQUEST['lastname'];

if ($firstname == 'Joey' and $lastname == 'Hodara')
{
	$output = 'Welcome to our site, ' . 
	htmlspecialchars($firstname, ENT_QUOTES, 'UTF-8') . ', Oh Glorious Leader!';

}

else 
{  

	if ($firstname == 'Matt' and $lastname == 'Fig') 
	{
		$output = 'Welcome to our site, ' . 
		htmlspecialchars($firstname, ENT_QUOTES, 'UTF-8') . ', Portagee!';
	}

	else{
		if ($firstname == 'Jon' and $lastname == 'Spense') 
		{
			$output = 'Welcome to our site, ' . 
			htmlspecialchars($firstname, ENT_QUOTES, 'UTF-8') . ', bro!';
		}

	}

	$output = 'Welcome to our site, ' . 
	htmlspecialchars($firstname, ENT_QUOTES, 'UTF-8') . ' ' . htmlspecialchars($lastname, ENT_QUOTES, 'UTF-8') . '!';




?>

Link to comment
https://forums.phpfreaks.com/topic/219866-multiple-ifelse-statements/
Share on other sites

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.