PHP redirection help!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bumple
Forum Commoner
Posts: 34
Joined: Thu Jan 08, 2004 4:38 am

PHP redirection help!

Post 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?!
mwong
Forum Commoner
Posts: 34
Joined: Sun Dec 28, 2003 2:58 am

Post by mwong »

viewtopic.php?t=1157

THat topic helped me alot. Try that!
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Re: PHP redirection help!

Post 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
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

And may I wonder why this isn't in the PHP Code forum? <_<

-Nay
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post 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 ;)
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

Dang, now let's move all the unhighlighted codes into here :D.

-Nay
User avatar
Pyrite
Forum Regular
Posts: 769
Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:

Post 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
Post Reply