Jump to content

PHP timed redirect


danposs86

Recommended Posts

I want to redirect after someone has logged in but the log in confirmation page is in an ECHO

<?phpif( $_POST['username'] != '' ){	require './sources/api/api_core.php';	require './sources/api/api_login.php';		$api = new api_login();	$api->path_to_ipb = dirname( __FILE__ ).'/';	$api->api_init();		$api->api_do_login( 'username', 'password', 1, 1 );		echo   "<?php header('Refresh: 4; URL=http://www.prestonscene.co.uk/index.php'); ?>			<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>			<html xmlns='http://www.w3.org/1999/xhtml'>			<head>			<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />			<link rel='stylesheet' media='screen' type='text/css' href='http://www.prestonscene.co.uk/stylesheet.css' />			<title>prestonscene /// </title>			</head><body>			<div class='login_area'>			<div class='login_title'>			  </div>			<div class='login_main'>			<div class='login_bold'>";			if ($api->error)				echo "Username or password incorrect. Please try again.";				else				echo "Login Successful";			echo "</div>			<div>			<br /><a href='http://www.prestonscene.co.uk/index.php?id=1' class='greylink'><< Home</a>			</div>			</div>			</div>			</body></html>";	exit;}?>

if you look at the first line you can see where i am trying to redirect and some php code, but it doesnt work. Any ideas?

Link to comment
Share on other sites

You don't put headers and stuff like that into echo's.Try this code instead:

<?phpif( $_POST['username'] != '' ){	require './sources/api/api_core.php';	require './sources/api/api_login.php';		$api = new api_login();	$api->path_to_ipb = dirname( __FILE__ ).'/';	$api->api_init();		$api->api_do_login( 'username', 'password', 1, 1 );		header('Refresh: 4; URL=http://www.prestonscene.co.uk/index.php');			<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>			<html xmlns='http://www.w3.org/1999/xhtml'>			<head>			<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />			<link rel='stylesheet' media='screen' type='text/css' href='http://www.prestonscene.co.uk/stylesheet.css' />			<title>prestonscene /// </title>			</head><body>			<div class='login_area'>			<div class='login_title'>			  </div>			<div class='login_main'>			<div class='login_bold'>";			if ($api->error)				echo "Username or password incorrect. Please try again.";				else				echo "Login Successful";			echo "</div>			<div>			<br /><a href='http://www.prestonscene.co.uk/index.php?id=1' class='greylink'><< Home</a>			</div>			</div>			</div>			</body></html>";	exit;}?>

Link to comment
Share on other sites

Anders is right, but he forgot the echo after header();

header('Refresh: 4; URL=http://www.prestonscene.co.uk/index.php');			echo "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>....

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...