/    Sign up×
Community /Pin to ProfileBookmark

Php Includes… Other Alternatives

I was wondering if there was an alternate way of automatically going to a different page without using an include.

For example…
if i have an if statement, and the statement returns true, i want to go to a different web page.

Let’s assume that it returns true.

I want to go to the other page, but i dont want it to be in the same page.

Like, i want the page name in the address bar to change and not stay on the same page like it does with includes.

Example…
[url]www.site.com/example.php[/url]

i want it to go to a different page automcatically and change to this..
[url]www.site.com/seperatePage.php[/url]

Can someone help?

Thanks.

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@SamFeb 04.2004 — the best way I have found to do this is:
[code=php]
if(false)
{
echo "<meta http-equiv="refresh" content="0;URL=seperatePage.php">";
}
[/code]
Copy linkTweet thisAlerts:
@CSmith1128authorFeb 04.2004 — Good Stuff... Exactly what i was looking for.. Thanks!
Copy linkTweet thisAlerts:
@pierskFeb 04.2004 — why not use:[code=php]if(false)
{
header("Location: seperatepage.php");
}[/code]
??
Copy linkTweet thisAlerts:
@AdamGundryFeb 04.2004 — You would be better off send a HTTP Location header as piersk suggested, which is more widely understood and more accessible. From the Web Content Accessibility Guidelines:

7.5 Until user agents provide the ability to stop auto-redirect, do not use markup to redirect pages automatically. Instead, configure the server to perform redirects.[/quote]
Adam

P.S. According to the HTTP 1.1 specification, you should specify an absolute URL with the Location header (i.e. with http://) but most browsers accept relative URLs.
Copy linkTweet thisAlerts:
@pierskFeb 04.2004 — Good call about the http:// bit. I'd forgotten about that.

Anywho, there is also the problem in that if you've sent stuff* to the browser before the redirect then you are a bit schtuck!

When this has happened to me before, I'm used the <meta> way of doing it.

[size=1]*technical term[/size]?
×

Success!

Help @CSmith1128 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...