Skip to main content
Known Participant
January 17, 2011
Question

Help with "else" option in if (isset($_COOKIE["super_secret_user"]))

  • January 17, 2011
  • 2 replies
  • 720 views

I am trying to have my index.php make a choice as to what it shows. I would like it to open a new page (index1.php) at the "else" Is this possible? And if it is... can someone show me the code to use.

Condition 1 welcomes the user (done)

Condition 2 opens  a log in page (need help)

Thank you for your time.

This topic is closed to new replies. Start a new post to keep the conversation going.

2 replies

January 26, 2011

Yes it is possible.

If you paste your code or URL, i can tell you how.

Depending on where the "else" statement occurs in your code you may either use:

<meta http-equiv='refresh' content='0; URL=index1.php'> // Only works if no headers are sent already

or you just call different content in the same index.php (that's why we have a dynamic page)

As long as the html content is wedged between the <?php if... { ?> and <? } else { ?>" statements it'll do.

The alternative content then after the "else" and you're good.

Don't forget the closing brackets in the end - <? } ?>

cheers,

ff

Ralph3616Author
Known Participant
January 27, 2011

Thanks fun factory for getting back to me on this. With much frustration and learning. I have resolved my problem.

Initially because I could not get this to work  header("Location: http://domain.com/index3.php"); I used include("index3.php"); That too led to issues so.. I figured out the problem with using the "header" command to jump to an alternate page and have it sort of working the way I want now

Thanks again for your offer to help