Current location: Hot Scripts Forums » Programming Languages » PHP » cannot modify header


cannot modify header

Reply
  #11 (permalink)  
Old 06-01-05, 07:31 PM
lordy lordy is offline
Newbie Coder
 
Join Date: May 2005
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
the webapge am playing with at the moment, i do the following to allow redirects in if statements.

ob_start();

at the start of the page
and then later on i might have the following


if ( ($NOF_REQUEST->Session("Logged_In_Real") != "True") ) {

header("location: http://sydsrv02/real_estate_admin.php"); exit;

} else {

rest of page here.


this solved my problem and it sounds just like yours
just ensure that ob_start() is at the start of the page
Reply With Quote
  #12 (permalink)  
Old 06-01-05, 07:49 PM
kalinchuk kalinchuk is offline
Wannabe Coder
 
Join Date: Jun 2004
Location: ...
Posts: 110
Thanks: 0
Thanked 0 Times in 0 Posts
thanks man, it works
Reply With Quote
  #13 (permalink)  
Old 06-01-05, 08:47 PM
alabaster_lynch alabaster_lynch is offline
Wannabe Coder
 
Join Date: Mar 2005
Posts: 103
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by kalinchuk
it still doesnt work...
here ismy code:
PHP Code:

<?php

$test 
"1";
echo 
"some text here...";
if(
$test == '1')
{
header("location: test2.php");
}
echo 
"...";
?>
and i get that error
the echo statement isn't needed if your condition is met...no one is going to see because it will process to quickly. Try something like this...
PHP Code:

<?php

if($test == 1)
  
header("location: test2.php");
echo 
'some text here';
echo 
'more text';
?>
Hope this help....Jose
Reply With Quote
  #14 (permalink)  
Old 06-02-05, 01:18 AM
dennispopel dennispopel is offline
Coding Addict
 
Join Date: Mar 2005
Posts: 263
Thanks: 0
Thanked 0 Times in 0 Posts
You can redirect at any point in your code provided that you do not echo anything to the browser. In your code the first echo is useless from the logical point of view - even if you could redirect after an echo, the user would not see this text as he would be promptly redirected to another page. Conclusion: Remove the first echo statement that goes before the header().
__________________
onPHP5.com - PHP5: Articles, News, Tutorials, Interviews, Software and more
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to create a header file in Visual C++? dummies_05 C/C++ 3 03-15-05 08:20 AM
Adding data to HTTP header perleo PHP 6 01-06-05 06:24 PM
Fsockopen Header Needed !! shadi PHP 3 12-10-04 02:08 AM
using function header() shadi PHP 2 08-14-04 03:55 AM
PHP header question khadlock PHP 2 09-23-03 08:17 AM


All times are GMT -5. The time now is 06:49 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.