|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
|||
|
|||
|
I am building a user login section that will redirect the user automatically to a web address stored in a database.
I have done this in ASP using Responce.Redirect and would like to know if PHP supports the same type of functionality. Thanks. |
|
#2
|
|||
|
|||
|
Use the HEADER function:
$url = "http://www.someplace.com"; header("Location: $url"); You need to execute the header function before sending any other text to the browser. |
|
#3
|
|||
|
|||
|
Thanks corker! I didn't realize it was going to be that simple.
|
|
#4
|
|||
|
|||
|
if the headers are already outputted and you want to use the header redirect, place ob_start() at the very top of your page, to suppress the headers from being sent out.
|
|
#5
|
|||
|
|||
|
or use
Code:
<script language="javascript"> location.href="yourpage.php"; </script>
__________________
-- Jason |
|
#6
|
|||
|
|||
|
oh, and if this is used in combination with for example an authentication system, you should do an exit() after the header call (if the headers are already sent or the browser ignores the location header, they'll be able to see the page if you don't call exit())
PHP Code:
__________________
Best Regards, Håvard Lindset |
|
#7
|
|||
|
|||
|
yes, good call Lindset. I found out about this just the other day,...lol I feel like a nUb, but thats what this is all about,...learning
![]() |
|
#8
|
|||
|
|||
|
Correction
PHP Code:
![]() |
|
#9
|
|||
|
|||
|
Re: Correction
Quote:
Why? die() is just an alias of exit() so both will work |
|
#10
|
|||
|
|||
|
Oh yes, you are right
I have the "bad" habit to take die() when I want to output the status and exit when I output nothing... it's for this reason i maked this mistake Conclusion : I will RTFM before posting philosophical replies ![]() |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Does PHP support a Redirect function? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|