Jump to content

The if Else statement


Mackey18

Recommended Posts

What about this one aswell?

 

if ( "Kevin" == $firstname and "Yank" == $lastname ) {

  echo( "Welcome, oh glorious leader!" );

}

 

which goes with the form I put in:

 

<FORM ACTION="welcome.php" METHOD=GET>

First Name: <INPUT TYPE=TEXT NAME="firstname"><BR>

Last Name: <INPUT TYPE=TEXT NAME="lastname">

<INPUT TYPE=SUBMIT VALUE="GO">

</FORM>

If you're using a form to submit the values, then they're accessed withing the form action script using the $_GET or $_POST superglobal arrays (assuming tou have register globals disabled, as you should)

 

if ( $_GET["firstname"] == "Kevin" ) {
  echo( "Welcome, oh glorious leader!" );
} else {
  echo( "Welcome, ".$_GET["firstname"]."!" );
}

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.