almightyegg Posted February 10, 2007 Share Posted February 10, 2007 I can do the whole header( 'location: link' ) OR die(mysql_error()); but what if I want to redirect after the <html> tag has gone? Quote Link to comment Share on other sites More sharing options...
trecool999 Posted February 10, 2007 Share Posted February 10, 2007 After the <html> tag has gone, or </html>? Quote Link to comment Share on other sites More sharing options...
almightyegg Posted February 10, 2007 Author Share Posted February 10, 2007 in between the 2 Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 10, 2007 Share Posted February 10, 2007 You can't use header, you have to use the meta-refresh html tag. Usually you should do all your processing before any html, so you might need to restructure. Also, header has nothing to do with mysql, so why have or die(mysql_error())? Quote Link to comment Share on other sites More sharing options...
trecool999 Posted February 10, 2007 Share Posted February 10, 2007 Why do you have die(mysql_error()); after a redirect??? Quote Link to comment Share on other sites More sharing options...
almightyegg Posted February 10, 2007 Author Share Posted February 10, 2007 oh i didn't know that. I have a load of checks and if they fail the checks then something is echoed but I want it to be echoed into my normal page layout and with the normal css so needing <html><head><body> etc... Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 10, 2007 Share Posted February 10, 2007 So during your checking, store the errors into variables. Then check if there are errors. If there are, print the html page with errors, otherwise redirect using header() Quote Link to comment Share on other sites More sharing options...
almightyegg Posted February 10, 2007 Author Share Posted February 10, 2007 right I've done this and it works fine in IE but in FF it shows errors logging in... login: <form method="POST" action="welcome.php"> <b>Email:</b><br /> <input class="first" type="text" name="email" /><br /> <b>Password:</b><br /> <input class="first" type="password" name="password" /><br /> <input class="second" type="submit" value="Login"> </form> welcome.php (checks if everything is ok): <? session_start(); // Session Start include 'db.php'; // Connect to DB $email = $_POST['email']; $password = $_POST['password']; setcookie(email, $email); setcookie(password, $password); if((!$email) || (!$password)){ echo "<html><head><title>PROBLEMS!</title><link rel='stylesheet' href='default.css'></head><body>Please enter ALL of the information! <br /></body></html>"; include 'index.php'; exit(); } // check if the user info validates the db if((!$email) || (!$password)){ echo "<html><head><title>PROBLEMS!</title><link rel='stylesheet' href='default.css'></head><body>Please enter ALL of the information! <br /></body></html>"; include 'index.php'; exit(); } $active = mysql_query("SELECT * FROM users WHERE email='$email' AND activated='1'") OR die(mysql_error()); $a = mysql_num_rows($active); if($a == 0){ echo "<html><head><title>PROBLEMS!</title><link rel='stylesheet' href='default.css'></head><body>You haven't activated your account yet. <a href='resend.php'>Resend code.</A></body></html>"; }else{ $sql = mysql_query("SELECT * FROM users WHERE email='$email' AND password='$password'"); $login_check = mysql_num_rows($sql); if($login_check == 0){ $sql1 = mysql_query("SELECT * FROM users WHERE email='$email'"); $sql2 = mysql_query("SELECT * FROM users WHERE email='$email' AND password='$password'"); $c1 = mysql_num_rows($sql1); $c2 = mysql_num_rows($sql2); if($c1==0){ echo "<html><head><title>PROBLEMS!</title><link rel='stylesheet' href='default.css'></head><body>There was a problem with your data entered!</body></html>"; include 'index.php'; }elseif($c2==0){ echo "<html><head><title>PROBLEMS!</title><link rel='stylesheet' href='default.css'></head><body>There was a problem with your data entered!</body></html>"; include 'index.php'; } }else{ header( 'Location: http://www.koggdesigns.co.uk/home.php' ); } } ?> home.php (welcome.php redirects here): <? session_start(); // Session Start include 'db.php'; // Connect to DB $email = $_COOKIE['email']; $password = $_COOKIE['password']; if((!$email) || (!$password)){ echo "<html><head><link rel='stylesheet' href='default.css'><title>PROBLEMS!</title></head><body>Please enter ALL of the information! <br /></body></html>"; include 'http://www.koggdesigns.co.uk/index.php'; exit(); }else{ $sql = mysql_query("SELECT * FROM users WHERE email='$email' AND password='$password'"); $login_check = mysql_num_rows($sql); if($login_check == 0){ echo"<html><head><link rel='stylesheet' href='default.css'><title>PROBLEMS!</title></head><body>There were errors logging in. <a href=http://www.koggdesigns.co.uk/index.phphttp://www.koggdesigns.co.uk/index.php>Try again!</a></body></html>"; exit(); }else{ ?> <!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> <link rel="stylesheet" href="default.css"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>The Community - Member Home</title> </head> <body> <? $sql = mysql_query("SELECT * FROM users WHERE email='$email'"); $mem = mysql_fetch_array($sql); ?> Home <? } } ?> </body> </html> I have no idea what's wrong. IE works fine but in FF it gets to home.php then says: Please enter ALL of the information! and shows the login form again Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.