Page 1 of 1

PHP redirection help!

Posted: Sun Jan 11, 2004 11:41 pm
by bumple
I've been working on this for quite some time now, and finally know what the problem is. My website registers user's username and password, and asks them for it in 'login.php'. If their informaiton is correct, I tried using a 'header()' statement to redirect them to 'login_success.php'. However, I can across this quote at php.net when researching headers:

[quote]
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.

[syntax=php]<html>
<?php
/* This will give an error. Note the output
* above, which is before the header() call */
header('Location: http://www.example.com/');
?>[/syntax]
[/quote]

It then goes on to say:
[quote]
Note: In PHP 4, you can use output buffering to get around this problem, with the overhead of all of your output to the browser being buffered in the server until you send it. You can do this by calling ob_start() and ob_end_flush() in your script, or setting the output_buffering configuration directive on in your php.ini or server configuration files.
[/quote]

I dont have access to my php.ini file, so how would I use ob_start or ob_end_flush in my code?

I have my header redirection in the heart of all my code, which is why it wasn't running. Thanks in advance!

-BUMPLE

P.S: WHY THE HELL DO MY QUOTES AND PHP SYNTAX HIGHLIGHTERS NEVER WORK?!

Posted: Mon Jan 12, 2004 12:00 am
by mwong
viewtopic.php?t=1157

THat topic helped me alot. Try that!

Re: PHP redirection help!

Posted: Mon Jan 12, 2004 3:07 am
by JayBird
bumple wrote:P.S: WHY THE HELL DO MY QUOTES AND PHP SYNTAX HIGHLIGHTERS NEVER WORK?!
go to your profile and check the option for "Always allow BBCode".

That should solve your problem.

Mark

Posted: Mon Jan 12, 2004 3:51 am
by Nay
And may I wonder why this isn't in the PHP Code forum? <_<

-Nay

Posted: Mon Jan 12, 2004 6:28 am
by Weirdan
Nay wrote:And may I wonder why this isn't in the PHP Code forum?
Just because it lacks proper php syntax highlighting ;)

Posted: Mon Jan 12, 2004 7:18 am
by Nay
Dang, now let's move all the unhighlighted codes into here :D.

-Nay

Posted: Mon Jan 12, 2004 9:29 pm
by Pyrite
That's the disadvantage of using the header for redirects. But anyways, you can set those php.ini settings for that page only using like the ini_set function or something.

http://us2.php.net/manual/en/function.ini-set.php