Page 1 of 1

Meta Refresh not working in IE7

Posted: Mon Jun 18, 2007 10:17 am
by thefreebielife

Code: Select all

<? session_start(); ?>
<? require("config.php"); ?>
<?
if (isset($_GET["form"]) && $_GET['form'] == "submit") { 
//get vars
$username2 = $_POST['username'];
$password2 = $_POST['password'];
$username = strtolower($username2);
$password = strtolower($password2);
if (isset($_POST['cookie'])) { $cookie = $_POST['cookie']; }
$time = time(); 
$pass = md5($password);

//check database
$sql="SELECT * FROM users WHERE username='$username' and password='$pass'";
$result=mysql_query($sql);
//check if there is a match
$count=mysql_num_rows($result);
if($count==1){
$data = mysql_query("SELECT * FROM users WHERE username='$username' and password='$pass'");
$info = mysql_fetch_array($data);
$ip = getenv('REMOTE_ADDR');
$date = date("F j, Y, g:i a"); 
$iplogs = mysql_query("SELECT * FROM `iplogs` WHERE iusername='$username' and iip='$ip'");
$logs = mysql_num_rows($iplogs);
if ($logs > 0) {
$iplogs2 = mysql_query("SELECT * FROM `iplogs` WHERE iusername='$username' and iip='$ip'");
$r = mysql_fetch_array($iplogs2);
$logins = $r['logins'];
$logins++;
$update="UPDATE `iplogs` SET logins='$logins' WHERE iusername='$username' and iip='$ip'";
mysql_query($update);
} else {
$insert = mysql_query("insert into iplogs values ('', '$username', '$date', '$ip', '1')");
}
$_SESSION['username'] = $info['username'];
$_SESSION['admin'] = $info['astatus']; 
$_SESSION['fname'] = $info['fname'];
if($cookie == "yes") {
setcookie("username", $info['username'], $time + 3600);        // Sets the cookie username
setcookie("password", $password, $time + 3600);    // Sets the cookie password
} 
}
if ($count != 1) { $login = "error"; }
}
?>
<html>
<head>
<title>The Freebie Life</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="style.css" />
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<center>
<table id="Table_01" width="780" height="1024" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td colspan="5">
			<a href="index.php"><img src="images/main_01.gif" alt="" width="780" height="26" border="0"></a></td>
	</tr>
	<tr>
		<td colspan="5">
			<img src="images/main_02.gif" width="780" height="10" alt=""></td>
	</tr>
	<tr>
		<td colspan="5">
			<a href="index.php"><img src="images/main_04.gif" alt="" width="780" height="229" border="0"></a></td>
	</tr>
	<tr>
		<td rowspan="4">
			<img src="images/main_05.gif" width="18" height="47" alt=""></td>
		<td colspan="3">
			<img src="images/main_06.gif" width="756" height="26" alt=""></td>
		<td rowspan="4">
			<img src="images/main_07.gif" width="6" height="47" alt=""></td>
	</tr>
	<tr>
		<td colspan="3">
			<img src="images/main_08.gif" width="756" height="12" alt=""></td>
	</tr>
	<tr>
		<td colspan="2">
			<img src="images/top.gif" width="755" height="1" alt=""></td>
		<td rowspan="2">
			<img src="images/right.gif" width="1" height="9" alt=""></td>
	</tr>
	<tr>
		<td>
			<img src="images/left.gif" width="1" height="8" alt=""></td>
		<td>
			<img src="images/main_12.gif" width="754" height="8" alt=""></td>
	</tr>
	<tr align="center" valign="top">
	  <td height="699" colspan="5" background="images/main_13.gif"><h1>&nbsp;</h1>
	  <font size="+3">Member Login</font> <br>
        <?
if (isset($_GET["form"]) && $_GET['form'] == "submit") { 
if($count==1) {
echo "<b><Center>You Have Now Been Logged In</center></b>";
echo '<meta http-equiv="refresh" content="2;url=main.php">';
exit;
}
}
 //check to see if already logged in
if (isset($_SESSION['username'])) { echo "<b><center>You Are Currently Logged In As ".$_SESSION['username']."</center></b><br>"; 
echo '<meta http-equiv="refresh" content="2;url=main.php">';
exit; }
//check to see if a cookie is set
if (isset($_COOKIE['username'])) {
$username = $_COOKIE['username'];
$password = $_COOKIE['password'];
$pass = md5($password);
//check database
$sql="SELECT * FROM users WHERE username='$username' and password='$pass'";
$result=mysql_query($sql);
//check if there is a match
$count=mysql_num_rows($result);
if($count==1){ 
$data = mysql_query("SELECT * FROM users WHERE username='$username' and password='$pass'")
or die(mysql_error());
$info = mysql_fetch_array($data);
$cname = $info['username'];
$cpassword = $_COOKIE['password'];
$cookie = "set";
}
}
?>  
	    <form action="login.php?form=submit" method="post" name="login">
      <table width="350" border="0" align="center" cellpadding="1" cellspacing="0" bordercolor="#FFFFFF" class="table">
        <tr>
          <? if ($login == "error") { ?>
          <td colspan="2" align="center"><? echo "<center><font color=red>Your Username or Password is Invalid</font></center>";  ?></td>
          <? } else {?>
          <td colspan="2">&nbsp;</td>
          <? } ?>
        </tr>
        <tr>
          <td width="122"><div align="left">&nbsp; Username: </div></td>
          <td width="307"><input name="username" type="text" value="<? echo "$cname"; ?>" size="25" /></td>
        </tr>
        <tr>
          <td><div align="left">&nbsp; Password: </div></td>
          <td><input name="password" type="password" id="Password" value="<? echo "$cpassword"; ?>" size="25" /></td>
        </tr>
        <? if ($cookie != "set") { ?><tr>
          <td colspan="2"><div align="center">
              <input name="cookie" type="checkbox" id="cookie" value="yes" />
        Remember Me </div></td>
        <tr>
		<? } ?>
		<td colspan="2"><div align="center">
			 <a href="forgot.php">Forgot Password</a>
          </div></td>
		  </tr>
		  <Tr>
          <td colspan="2"><div align="center">
              <input name="submitbutton" type="submit" class="button" value="Submit">
          </div></td>
        </tr>
        <tr>
          <td colspan="2">&nbsp;</td>
        </tr>
      </table>  </form>    <p>&nbsp;</p></td>
	</tr>
In IE7 the "meta refresh" does not take the user to main.php but rather to login.php AGAIN. this is only happening in IE7.. does anyone have any ideas?

Posted: Mon Jun 18, 2007 10:26 am
by volka
try

Code: Select all

...
if (isset($_GET["form"]) && $_GET['form'] == "submit") {
  if($count==1) {
    echo "<b><Center>You Have Now Been Logged In</center></b>";
    echo '<meta http-equiv="refresh" content="2;url=main.php">';
    exit;
  }
  else {
    echo '<div>Debug: ', __FILE__, '@', __LINE__, ' !($count==1)</div>';
  }
}
else {
  echo '<div>Debug: ', __FILE__, '@', __LINE__, ' !(isset($_GET["form"]) && $_GET[form] == "submit")</div>';
}

 //check to see if already logged in
if (isset($_SESSION['username'])) {
  echo "<b><center>You Are Currently Logged In As ".$_SESSION['username']."</center></b><br>";
  echo '<meta http-equiv="refresh" content="2;url=main.php">';
  exit;
}
else {
  echo '<div>Debug: ', __FILE__, '@', __LINE__, ' !(isset($_SESSION[username]))</div>';
}
//check to see if a cookie is set
...

Posted: Mon Jun 18, 2007 10:28 am
by jamiel
Your meta tags should be in the head of the document and closed properly <meta foo=bar /> .

Posted: Mon Jun 18, 2007 11:02 am
by thefreebielife
volka, im getting this error using your code:

Code: Select all

Debug: /home/primod/public_html/mcd/mcd/login.php@107 !(isset($_GET["form"]) && $_GET[form] == "submit")
Debug: /home/primod/public_html/mcd/mcd/login.php@117 !(isset($_SESSION[username]))

Posted: Mon Jun 18, 2007 11:08 am
by volka
meaning: neither
if (isset($_GET["form"]) && $_GET['form'] == "submit") {
nor
if (isset($_SESSION['username'])) {
is satisfied and therefore no meta/refresh is printed.

Posted: Mon Jun 18, 2007 11:13 am
by thefreebielife
but this works in all other browsers including old IE's

Posted: Mon Jun 18, 2007 11:19 am
by volka
Then you should print the contents of $_GET and $_SESSION for debugging

Code: Select all

...
<link rel="stylesheet" href="style.css" />
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">

<pre>_GET: <?php print_r($_GET); ?></pre>
<pre>_SESSION: <?php print_r($_SESSION); ?></pre>

<center>
<table id="Table_01" ...

Posted: Mon Jun 18, 2007 4:35 pm
by thefreebielife

Code: Select all

_GET: Array
(
)

_SESSION: Array
(
)
This is what i got. im at a loss for what to do

Posted: Mon Jun 18, 2007 4:43 pm
by superdezign
I'm confused as to why you can't just use header(). :?

You're using the meta tag... incorrectly. I'm pretty sure that it's meant to be in a <head> element. Kudos for IE7 if it's the only one that enforces the rule. :P

Posted: Mon Jun 18, 2007 6:42 pm
by thefreebielife
so you're saying this would be correct (untested):

Code: Select all

<? session_start(); ?>
<? require("config.php"); ?>
<?
if (isset($_GET["form"]) && $_GET['form'] == "submit") {
//get vars
$username2 = $_POST['username'];
$password2 = $_POST['password'];
$username = strtolower($username2);
$password = strtolower($password2);
if (isset($_POST['cookie'])) { $cookie = $_POST['cookie']; }
$time = time();
$pass = md5($password);

//check database
$sql="SELECT * FROM users WHERE username='$username' and password='$pass'";
$result=mysql_query($sql);
//check if there is a match
$count=mysql_num_rows($result);
if($count==1){
$data = mysql_query("SELECT * FROM users WHERE username='$username' and password='$pass'");
$info = mysql_fetch_array($data);
$ip = getenv('REMOTE_ADDR');
$date = date("F j, Y, g:i a");
$iplogs = mysql_query("SELECT * FROM `iplogs` WHERE iusername='$username' and iip='$ip'");
$logs = mysql_num_rows($iplogs);
if ($logs > 0) {
$iplogs2 = mysql_query("SELECT * FROM `iplogs` WHERE iusername='$username' and iip='$ip'");
$r = mysql_fetch_array($iplogs2);
$logins = $r['logins'];
$logins++;
$update="UPDATE `iplogs` SET logins='$logins' WHERE iusername='$username' and iip='$ip'";
mysql_query($update);
} else {
$insert = mysql_query("insert into iplogs values ('', '$username', '$date', '$ip', '1')");
}
$_SESSION['username'] = $info['username'];
$_SESSION['admin'] = $info['astatus'];
$_SESSION['fname'] = $info['fname'];
if($cookie == "yes") {
setcookie("username", $info['username'], $time + 3600);        // Sets the cookie username
setcookie("password", $password, $time + 3600);    // Sets the cookie password
}
}
if ($count != 1) { $login = "error"; }
}
?>
<html>
<head>
<title>The Freebie Life</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="style.css" />
        <?
if (isset($_GET["form"]) && $_GET['form'] == "submit") {
if($count==1) {
echo "<b><Center>You Have Now Been Logged In</center></b>";
echo '<meta http-equiv="refresh" content="2;url=main.php">';
exit;
}
}
 //check to see if already logged in
if (isset($_SESSION['username'])) { echo "<b><center>You Are Currently Logged In As ".$_SESSION['username']."</center></b><br>";
echo '<meta http-equiv="refresh" content="2;url=main.php">';
exit; }
//check to see if a cookie is set
if (isset($_COOKIE['username'])) {
$username = $_COOKIE['username'];
$password = $_COOKIE['password'];
$pass = md5($password);
//check database
$sql="SELECT * FROM users WHERE username='$username' and password='$pass'";
$result=mysql_query($sql);
//check if there is a match
$count=mysql_num_rows($result);
if($count==1){
$data = mysql_query("SELECT * FROM users WHERE username='$username' and password='$pass'")
or die(mysql_error());
$info = mysql_fetch_array($data);
$cname = $info['username'];
$cpassword = $_COOKIE['password'];
$cookie = "set";
}
}
?> 
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<center>
<table id="Table_01" width="780" height="1024" border="0" cellpadding="0" cellspacing="0">
        <tr>
                <td colspan="5">
                        <a href="index.php"><img src="images/main_01.gif" alt="" width="780" height="26" border="0"></a></td>
        </tr>
        <tr>
                <td colspan="5">
                        <img src="images/main_02.gif" width="780" height="10" alt=""></td>
        </tr>
        <tr>
                <td colspan="5">
                        <a href="index.php"><img src="images/main_04.gif" alt="" width="780" height="229" border="0"></a></td>
        </tr>
        <tr>
                <td rowspan="4">
                        <img src="images/main_05.gif" width="18" height="47" alt=""></td>
                <td colspan="3">
                        <img src="images/main_06.gif" width="756" height="26" alt=""></td>
                <td rowspan="4">
                        <img src="images/main_07.gif" width="6" height="47" alt=""></td>
        </tr>
        <tr>
                <td colspan="3">
                        <img src="images/main_08.gif" width="756" height="12" alt=""></td>
        </tr>
        <tr>
                <td colspan="2">
                        <img src="images/top.gif" width="755" height="1" alt=""></td>
                <td rowspan="2">
                        <img src="images/right.gif" width="1" height="9" alt=""></td>
        </tr>
        <tr>
                <td>
                        <img src="images/left.gif" width="1" height="8" alt=""></td>
                <td>
                        <img src="images/main_12.gif" width="754" height="8" alt=""></td>
        </tr>
        <tr align="center" valign="top">
          <td height="699" colspan="5" background="images/main_13.gif"><h1>&nbsp;</h1>
          <font size="+3">Member Login</font> <br>
            <form action="login.php?form=submit" method="post" name="login">
      <table width="350" border="0" align="center" cellpadding="1" cellspacing="0" bordercolor="#FFFFFF" class="table">
        <tr>
          <? if ($login == "error") { ?>
          <td colspan="2" align="center"><? echo "<center><font color=red>Your Username or Password is Invalid</font></center>";  ?></td>
          <? } else {?>
          <td colspan="2">&nbsp;</td>
          <? } ?>
        </tr>
        <tr>
          <td width="122"><div align="left">&nbsp; Username: </div></td>
          <td width="307"><input name="username" type="text" value="<? echo "$cname"; ?>" size="25" /></td>
        </tr>
        <tr>
          <td><div align="left">&nbsp; Password: </div></td>
          <td><input name="password" type="password" id="Password" value="<? echo "$cpassword"; ?>" size="25" /></td>
        </tr>
        <? if ($cookie != "set") { ?><tr>
          <td colspan="2"><div align="center">
              <input name="cookie" type="checkbox" id="cookie" value="yes" />
        Remember Me </div></td>
        <tr>
                <? } ?>
                <td colspan="2"><div align="center">
                         <a href="forgot.php">Forgot Password</a>
          </div></td>
                  </tr>
                  <Tr>
          <td colspan="2"><div align="center">
              <input name="submitbutton" type="submit" class="button" value="Submit">
          </div></td>
        </tr>
        <tr>
          <td colspan="2">&nbsp;</td>
        </tr>
      </table>  </form>    <p>&nbsp;</p></td>
        </tr>

Posted: Mon Jun 18, 2007 10:02 pm
by superdezign
.....

No.

The <head> tag holds <meta>, <link>, <title>, <script>, and <style>.

The <b> tag is invalid in the <head>, and <center> is deprecated completely.


I *still* don't see why you can't just use header(). Why both printing anything if they are being redirected?

Posted: Mon Jun 18, 2007 10:42 pm
by thefreebielife
i've never used header() before (at least i think i haven't) so i would know where to begin

Posted: Mon Jun 18, 2007 10:46 pm
by feyd
The documentation. ;)
header()