>How do I get PHP to automatically open another PHP page in a browser if a
>condition is met?
>
> I have a pull down HTML table that submits a form to a PHP script.  That
>script then uses a little logic to figure out which web page to go to.  I
>have 5 different pages, and each has different content.  Right now, I can
>make it bring up links, but I can't figure a way out to make it
>automatically go to the proper web page.
>
>I know this has to be easy, but I can't find any info one it.

First some Good News:

Here's a couple quickie options:

1. Use http://php.net/include to just suck in the other file to the "shell"
that you've built.
2. Use http://php.net/header as header("Location: $otherpage"); to re-direct
the browser.

Now, some meta-comments about these techniques.

1. Seems really nice, until you have to come back to the page and maintain
it a couple years down the line.  It gets really messy to figure out what
variables are coming from where when you have this shell game going on
sucking in different files based on a variable.  You can work with it, but
expect to end up investing more in maintenance than you should

2. is really an abusive use of a mechanism for pages that *MOVED* --
header("Location: ") is really not the right weapon for programming
site/layout.  It was designed for pages that have literally been picked up
and moved to another URL/server/whatever.  It *can* be used to force the
user to jump around inside your site, but that was not its intent, and will
be problematic.  One specific instance is that you'll end up not being able
to use Cookies/Sessions reliably because the "re-location" happens before
the Cookie makes it out the door.

Now, for the Bad News:
You really need to re-think the "big picture" of the design of your web-site
so that you don't have to do this.

You can use JavaScript in your HTML to re-direct the user to a different
page, and leave PHP out of the page-choosing logic.  But then you are
relying on JavaScript which is unreliable, and some users don't even have
it.

It may "work" for the sites you visit (for *you*) and you may find it
attractive, but there *will* be users who leave your site because it doesn't
work.

Your best bet is to not use an HTML pop-up menu for navigation at all. 
There is no reliable way using maintainable code that will make it really
work.

-- 
Like Music?  http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to