header("Location: .....") Question
Posted: Wed Oct 13, 2004 9:41 am
I've noticed on my page that when I use header("Location: ....") to redirect the visitor to another site, the original page seems to continue executing. Is this supposed to happen? If so, is there a way to halt execution after the redirection header is sent?
For example, on my site there is a regular expression that passwords must match to be considered "secure" for the purposes of the site. If a password chosen does not match that regular expression, then the visitor is redirected back to the form so they can enter a new password. However, I noticed that the erroneous password still gets saved in the database. When the user makes a new, "secure" password the erroneous one is replaced with the good one. However, if the user decides to stop after getting an error thinking that they'll just keep their old password, they actually have the erroneous one.
I can't figure out what's going on unless the header() function does not halt execution when the "Location: ...." header is sent.
Also, my trusty O'Reilly's Programming PHP manual states that you shoul use an absolute path to the file you redirect to. It's been working fine for me with relative paths (except for the problem detailed above). Could this be the reason for the above problem? If not, what's the point of coding the absolute path into the header("Location: ...") function calls?
Thanks a bunch,
David Goldfeder
Web and Database Specialist
University of Illinois, Urbana-Champaign
Department of Mechanical and Industrial Engineering
For example, on my site there is a regular expression that passwords must match to be considered "secure" for the purposes of the site. If a password chosen does not match that regular expression, then the visitor is redirected back to the form so they can enter a new password. However, I noticed that the erroneous password still gets saved in the database. When the user makes a new, "secure" password the erroneous one is replaced with the good one. However, if the user decides to stop after getting an error thinking that they'll just keep their old password, they actually have the erroneous one.
I can't figure out what's going on unless the header() function does not halt execution when the "Location: ...." header is sent.
Also, my trusty O'Reilly's Programming PHP manual states that you shoul use an absolute path to the file you redirect to. It's been working fine for me with relative paths (except for the problem detailed above). Could this be the reason for the above problem? If not, what's the point of coding the absolute path into the header("Location: ...") function calls?
Thanks a bunch,
David Goldfeder
Web and Database Specialist
University of Illinois, Urbana-Champaign
Department of Mechanical and Industrial Engineering