Jump to content

simple else statement help


dabempire

Recommended Posts

I know very little about php.  I hoping someone can help with a simple feature.  I want my php page to print one of two things.  Certain incoming links to my site will come in like:

 

www.domain.com/?header1=test1&header2=test2

 

If header1 is not present in the url I want it to print static content.  If there is a header1 variable in the url I want to to print what it says.

 

Header 2 was easy, it's always: <?php echo $_GET["header2"]; ?>

 

For header 1 I have the following, but I don't know how to complete it.

 

<h1>
<?php
if ($header1 == null) {
    echo "We're Here to Help";
} else {
    WHAT_GOES_HERE
}
?>
</h1>

 

 

First question:  Do I use "null" or is there something better to see if there's even a header1 at all?

 

Second question:  How do I finsh the else part to print whatever header1 is in the variable?

Link to comment
https://forums.phpfreaks.com/topic/91711-simple-else-statement-help/
Share on other sites

Thanks for the reply.  I just noticed I messed up a bit.  I need the if to print the variable.

 

<h1>

<?php

if (isset($_GET['header1']))

{

    HOW_TO_PRINT_HEADER1_HERE

}

else

{

    We're Here to Help

}

?>

</h1>

 

How would I add that?

 

Thanks again.

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.