ajclarkson Posted June 7, 2008 Share Posted June 7, 2008 Sorry to have to post this guys but I have been attempting to fix this for the best part of 3 hours now. I have a login system, based around a third party one but I have written it in my own way so I have a good understanding about how it all works. Now, basically there is a central page "process.php" which takes the input data from forms, processes it and redirects the user as appropriate. It processes the data fine, but the redirect doesn't work, I get no errors, no output to the screen, just a blank page, which is process.php The offending code is: <? /** * Process.php * * */ include("./session.php"); class Process{ /* Class constructor */ function Process(){ global $session; if(isset($_POST['sublogin'])){ $this->procLogin(); } else if(isset($_POST['subjoin'])){ $this->procRegister(); } else if(isset($_POST['subforgot'])){ $this->procForgotPass(); } else if(isset($_POST['subedit'])){ $this->procEditAccount(); } else if($session->logged_in){ $this->procLogout(); }else{ header("Location: ./index.php"); } } function procLogin(){ global $session, $form; $retval = $session->login($_POST['user'], $_POST['pass'], isset($_POST['remember'])); if($retval){ header("Location: ".$session->referrer); } else{ $_SESSION['value_array'] = $_POST; $_SESSION['error_array'] = $form->getErrorArray(); header("Location: ./index.php"); } } which then continues. It is the third line from the bottom which concerns me most (as I have no users yet therefore login always fails). Now I have checked everything suggested in the sticky, and as far as I can see there is no white space preceeding or trailing the <? tags here, or in any of the referenced files. Please can you help, as this really needs to get working asap and I have looked at it for so long I probably wont spot something straightforward anymore. Many Thanks in advance ajclarkson Link to comment https://forums.phpfreaks.com/topic/109127-solved-redirection-problemyes-ive-read-the-sticky/ Share on other sites More sharing options...
phpzone Posted June 7, 2008 Share Posted June 7, 2008 You just have the closing brace for the class missing. <?php /** * Process.php * * */ include("./session.php"); class Process { /* Class constructor */ function Process() { global $session; if( isset( $_POST['sublogin'] ) ) { $this->procLogin(); } else if( isset($_POST['subjoin'] )) { $this->procRegister(); } else if( isset($_POST['subforgot']) ) { $this->procForgotPass(); } else if( isset($_POST['subedit']) ) { $this->procEditAccount(); } else if($session->logged_in) { $this->procLogout(); } else { header("Location: ./index.php"); } } function procLogin() { global $session, $form; $retval = $session->login( $_POST['user'], $_POST['pass'], isset($_POST['remember']) ); if ( $retval ) { header("Location: ". $session->referrer ); } else { $_SESSION['value_array'] = $_POST; $_SESSION['error_array'] = $form->getErrorArray(); header("Location: ./index.php"); } } } ?> A couple of comments also, you don't need to take these on board but they may be useful: a) best to use <?php opening tag rather than shorttag <? b) be aware 'header' does not terminate a script, so it could potentially drop through to other code, I always do exit( header('Location: index.php') ); c) include() does not need brackets, PHP doesn't complain, but you don't need them include "myfile.php"; would do, also, better to use require_once or include_once Link to comment https://forums.phpfreaks.com/topic/109127-solved-redirection-problemyes-ive-read-the-sticky/#findComment-559773 Share on other sites More sharing options...
ajclarkson Posted June 7, 2008 Author Share Posted June 7, 2008 Sorry I forgot to mention in the original post that this is only the first part of process.php!! my bad, thanks for the other suggestions though! Link to comment https://forums.phpfreaks.com/topic/109127-solved-redirection-problemyes-ive-read-the-sticky/#findComment-559778 Share on other sites More sharing options...
ajclarkson Posted June 8, 2008 Author Share Posted June 8, 2008 I sorted this this morning. For any future users having a similar problem. I trawled through all of the scripts which could possibly have an impact on this one and found a tab after a ?> tag in a very remote file, removing this seems to have done the trick, it appears after 2 hours of doing this yesterday this one slipped under the radar! Now to work out why my database is refusing to match up usernames! Link to comment https://forums.phpfreaks.com/topic/109127-solved-redirection-problemyes-ive-read-the-sticky/#findComment-560337 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.