plznty Posted November 14, 2008 Share Posted November 14, 2008 <?php // valid login credentials $user = $_POST['user']; include ("archives/sql.php"); $sql=mysql_query("SELECT * FROM `login` WHERE Username='$user'") or die (mysql_error()); while($row=mysql_fetch_array($sql)) { $username="$row[username]"; $password="$row[Password]"; } // grab current time $time=time(); // handle the logout event if ($logout == true) { setcookie ("user", $_POST[user], $time-3200); setcookie ("pass", md5($_POST[pass]), $time-3200); header("Location: admin.php"); } // handle validation event if ($_POST[user] && $_POST[pass]) { if ($_POST[user]==$username && $_POST[pass]==$password) { setcookie ("user", $_POST[user], $time+3200); setcookie ("pass", md5($_POST[pass]), $time+3200); header("Location: validate.php"); } else { $login_error= true; } } // handle login event, both successful and erroneous, or show login screen if ($login_error == true) { include("archives/sql.php"); echo "<center><img src='themes/$theme/header.gif'></center><hr>"; ?> <table align=center style="font-family:arial; font-size:12; border:1 solid #000000;"> <tr><td align=center bgcolor=#123dd4>LOGIN ERROR</td></tr> <tr><td align=center><b>Invalid Username and/or Password</b><br><br><a href=admin.php>Back</a></td></tr> </table><p> <? } elseif ($_COOKIE[user] == md5($username) && $_COOKIE[pass] == md5($password)) { echo "<center><img src='themes/$theme/header.gif'></center><hr>"; echo "<center><p><h3>Thank you. You will now be redirected.</h3><p><a href='main.php'>Click here if you do not wish to wait.</a>"; echo '<META HTTP-EQUIV="Refresh" CONTENT="2; URL=main.php">'; } else { echo "<center><img src='themes/$theme/header.gif'></center><hr>"; echo "<center><p><h3>Thank you. You will now be redirected.</h3><p><a href='main.php'>Click here if you do not wish to wait.</a>"; echo '<META HTTP-EQUIV="Refresh" CONTENT="2; URL=main.php">'; }; ?> Even if i type in the write password and user it dont work? Anyone care to help without alteration 2 much Added code tags ~ CV Link to comment https://forums.phpfreaks.com/topic/132773-login-problems/ Share on other sites More sharing options...
.josh Posted November 14, 2008 Share Posted November 14, 2008 -did you echo out your form vars to see if they are what you expect? -did you echo out your queried vars to see if they are what you expect? -be more specific than "it don't work." What is it supposed to do? What is it not doing? What is it doing instead? etc... -please use code tags when posting code. Link to comment https://forums.phpfreaks.com/topic/132773-login-problems/#findComment-690493 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.