danposs86 Posted April 30, 2007 Share Posted April 30, 2007 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 More sharing options...
Anders Moen Posted April 30, 2007 Share Posted April 30, 2007 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 More sharing options...
Mr_CHISOL Posted May 1, 2007 Share Posted May 1, 2007 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 More sharing options...
danposs86 Posted May 1, 2007 Author Share Posted May 1, 2007 cheers for your help, works perfectly Link to comment Share on other sites More sharing options...
Anders Moen Posted May 1, 2007 Share Posted May 1, 2007 Oops, I didn't notice the doctype and stuff was in the <?php ?> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.