thefreebielife Posted June 19, 2007 Share Posted June 19, 2007 <? 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> </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"> </td> <? } ?> </tr> <tr> <td width="122"><div align="left"> Username: </div></td> <td width="307"><input name="username" type="text" value="<? echo "$cname"; ?>" size="25" /></td> </tr> <tr> <td><div align="left"> 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"> </td> </tr> </table> </form> <p> </p></td> </tr> This code does not "refresh" the user to main.php but rather back to login.php. And yes, this is only an IE 7 problem, im completely flustered Quote Link to comment Share on other sites More sharing options...
Caesar Posted June 20, 2007 Share Posted June 20, 2007 Why not just use the header function? <?php header("location: main.php"); ?> Quote Link to comment Share on other sites More sharing options...
thefreebielife Posted June 20, 2007 Author Share Posted June 20, 2007 so instead of this: <?php echo "<b><Center>You Have Now Been Logged In</center></b>"; echo '<meta http-equiv="refresh" content="2;url=main.php">'; ?> use this?: <?php echo "<b><Center>You Have Now Been Logged In</center></b>"; header("location: main.php"); ?> Quote Link to comment Share on other sites More sharing options...
redarrow Posted June 20, 2007 Share Posted June 20, 2007 also this will refresh in 2 seconds. example. <?php echo "<b><Center>You Have Now Been Logged In</center></b>"; header('refresh; 2; url=main.php'); ?> Quote Link to comment Share on other sites More sharing options...
thefreebielife Posted June 20, 2007 Author Share Posted June 20, 2007 error im getting: *Warning*: Cannot modify header information - headers already sent by (output started at /home/primod/public_html/mcd/mcd/login.php:58) in */home/primod/public_html/mcd/mcd/login.php* on line *105* like 58 is my first image sliced link Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 20, 2007 Share Posted June 20, 2007 also this will refresh in 2 seconds. example. <?php echo "<b><Center>You Have Now Been Logged In</center></b>"; header('refresh; 2; url=main.php'); ?> <?php header('refresh; 2; url=main.php'); exit(); ?> ASTIG!!! just to be sure that it will not read your echo thing Quote Link to comment Share on other sites More sharing options...
thefreebielife Posted June 20, 2007 Author Share Posted June 20, 2007 now its not even refreshing in firefox :-\ Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 20, 2007 Share Posted June 20, 2007 but at least it works on IE lol try to remove the exit Quote Link to comment Share on other sites More sharing options...
lupld Posted June 20, 2007 Share Posted June 20, 2007 Just to be redundant, make sure the header comes before any html in the page, that includes the <html> tag... or you get a header error... there's a big article about it on the top of the help page... Quote Link to comment Share on other sites More sharing options...
lupld Posted June 20, 2007 Share Posted June 20, 2007 The refresh tag works fine in IE, I just checked... I had that problem too.. you can't have it echo up there, you have to make sure it echo's back or is written inside the head tag in IE... Like this is what I use in my login script... <? session_start(); if(!session_is_registered("username")){ header("location:http://www.example.com/login.php"); } ?> <html> <head> <title>Logged In</title> <LINK REL=StyleSheet HREF="color.css" TYPE="text/css"> <meta http-equiv="Refresh" Content="3; URL=home.php"> </head> <body><div align="center"><div style="height: 210px;"></div> <h1>Hello <? echo $_SESSION['username']; ?>! You are now Logged in.</h1> <h3>If you are not automatically forwarded to the homepage, <a href="home.php">Click Here.</a></h3> </div></body> </html> But you'd probably want to ignore the header part, cause you're having issues with headers... 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.