dabempire Posted February 18, 2008 Share Posted February 18, 2008 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? Quote Link to comment Share on other sites More sharing options...
elpaisa Posted February 18, 2008 Share Posted February 18, 2008 <h1> <?php if (isset($_GET['header1'])) { echo "We're Here to Help"; } else { Your html static content } ?> </h1> Quote Link to comment Share on other sites More sharing options...
dabempire Posted February 18, 2008 Author Share Posted February 18, 2008 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. Quote Link to comment Share on other sites More sharing options...
dabempire Posted February 18, 2008 Author Share Posted February 18, 2008 Got it figured out. Thanks. For others reading, here's the solution: <?php if (isset($_GET['header1'])) { echo $_GET['header1']; } else { echo "We're Here to Help"; } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.