Jump to content

[SOLVED] redirect


almightyegg

Recommended Posts

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())?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.