PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 29th, 2004, 03:59 PM
lanfz lanfz is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 1 lanfz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Headers with include!

Hi,

I'm new to PHP and I'm having some trouble to figure out how to solve a prob.
I want to evaluate a criteria inside a control structure statement, which needs some variables from an include, like this:

Code:
 include 'myinclude.php';
 
 if ($example){
 	   //code goes here
 	   }else{
 			 header("Location: http://example.com");
 		}
 


The problem is that I can't redirect my page after the else statement because of the include (I suppose). How could I solve this or is there a way I can redirect with PHP after the "else" without getting the header error?

'Warning: Cannot modify header information - headers already sent by'

Thanks a lot

Reply With Quote
  #2  
Old June 30th, 2004, 03:06 AM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
1 - The clean way - http://www.php.net/ob_start

2 - The ghetto way - Use the function: headers_sent() http://www.php.net/headers_sent to find out if headers (output) has been sent to the browser already... if not, use a Location / Header, otherwise, you will simply output an html based header (client side header)
__________________
__________________________________________________ _
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Are You Listed...? | DigitallySmooth Inc.

Reply With Quote
  #3  
Old June 30th, 2004, 03:07 AM
digitallysmooth digitallysmooth is offline
you know how we do
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jun 2002
Posts: 788 digitallysmooth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 m 21 sec
Reputation Power: 7
BTW, you will find most of what you need in the user comments on the www.php.net site:

http://us2.php.net/headers_sent

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Headers with include!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT