Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Direct to Page 1

Status
Not open for further replies.

dmears1

Technical User
Jun 18, 2003
208
US
Probably a simple solution but I'm unable to figure it out or find a solution online.
I want to check for an error, if there is one I want it to redirect to a certain page, if not I want to include a page. What I have so far is this:

Code:
if($error) {
include("contact.php");
}
else {
include("feedbacksent.php");
}
The "else" part of the code is fine. Instead of "including" contact.php I want it to load that page. How would I do that???

 
Code:
if($error) {
header("Location: contact.php");
}
else {
include("feedbacksent.php");
}
There had to be no output before the header call for it to work. No echos, no prints, no html code outside php brackets and no whitespace (carriage return, space) before the php brackets.
 
Thanks for the quick help. Unfortunately there is HTML code before the PHP code. I get the following error when using the code:

Warning: Cannot modify header information - headers already sent

 
Can you restructure your script to not output anything before the redirection. If not, you will need to rely on client side redirection via meta tag or javascript.
 
Thanks again Vragabond. I don't think that I can restructure the script to work so I'll just have to work with the includes. Thanks again.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top