Jump to content

[SOLVED] Redirection Problem...Yes I've Read the Sticky.


ajclarkson

Recommended Posts

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

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

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!

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.