On 15/11/06, Programmer <prog@xxxxxxxx> wrote:
Problem solved: the reason print($url) caused the program to work is because the page calling Secure_Login no longer existed and therefore the print forced a die--I assume. I included a die in the redirect function and all was well. Including die in the redirect function made sure the page that was redirected stop executing. The final question to the PHP community with this issue is: if a page myphppage.php has a redirect in it, how can it execute code after the redirect if it no longer exists? Is it because the server side code cares not that it has been redirected and only what is happing inside the php code? Thanks, Jeremy Schreckhise M.B.A. -----Original Message----- From: Programmer [mailto:prog@xxxxxxxx] Sent: Wednesday, November 15, 2006 10:53 AM To: php-general@xxxxxxxxxxxxx; 'Brandon Stewart' Subject: Function Misbehaving The following function is a basic user auth prep procedure for multiple pages. If the url desired is different than the default a url is supplied. This function works most of the time flawlessly; except, on some pages when the url has a value that was passed, the function still thinks url is NULL until it is used, such as printing it or assigning another variable its contents. Another way to eliminate this sporadic problem is to rename the parameter url to something else, such as url2. There are no global or session vars with the url name. Why does php think url is null when it is not, but only fault in this manner part of the time. Any help would be appreciated. // Code function Secure_Login($user,$pass,$db,$pg,$url=NULL) { //print($url); if I uncomment this url is no longer null or if I rename url to url2 $checkuser = is_user($user,$pass,$db); if (!$checkuser) { Secure_Email($pg); if(isset($url)) { Go_Page($url); } else { Go_Page("./login.php?login_error=2"); } } } Jeremy Schreckhise, M.B.A. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Do you have exit after the redirect? Try: <?php header("Location: http://www.example.com/"); /* Redirect browser */ /* Make sure that code below does not get executed when we redirect. */ exit; ?> See http://uk.php.net/header for more info. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php