Login system not working...?
Posted: Fri Jul 03, 2009 7:25 am
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Hey everybody!
Im having a little problem with my login system, that is, its just not working....
Its probably just something small that I missed, but could somebody please point me in the right direction?
Thank you in advance!
Here is my code:
index.php:
login.php:
success.php:
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
Hey everybody!
Im having a little problem with my login system, that is, its just not working....
Its probably just something small that I missed, but could somebody please point me in the right direction?
Thank you in advance!
Here is my code:
index.php:
Code: Select all
<h1>Multiflora Admin</h1>
<h2>Please enter your login details below:</h2>
<h2 class="error"><?php if ($_GET["error"]!=""); echo ("$_GET[error]")?></h2>
<form action="login.php" name="adminloginform" id="adminloginform" method="post">
<table width="195" cellpadding="2" cellspacing="0" border="0">
<tr><td><label for="username">Username</label></td><td align="right"><input name="adminuser" type="text" id="adminuser" size="15" /></td></tr>
<tr><td><label for="password">Password</label></td><td align="right"><input name="adminpass" type="password" id="adminpass" size="15" /></td></tr>
<tr><td colspan="2" id="buttons"><input type="submit" value="Login" name="login" id="login" /><input type="reset" value="Reset" name="reset" id="reset" /></td></tr>
</table>
</form>Code: Select all
<?
$host="localhost";
$username="root";
$password="";
$db_name="multiflora";
$tbl_name="admin";
$con=mysql_connect("$host","$username","$password")
or die("Cannot connect");
mysql_select_db("$db_name")
or die("Cannot Select Database");
$adminuser=$_POST['adminuser'];
$adminpass=$_POST['adminpass'];
$adminuser = stripslashes($adminuser);
$adminpass = stripslashes($adminpass);
$adminuser = mysql_real_escape_string($username);
$adminpass = mysql_real_escape_string($adminpass);
$sql="SELECT * FROM $tbl_name WHERE username='$adminuser' and password='$adminpass'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if($count==1){
session_register("adminuser");
session_register("adminpass");
header("location:success.php");
}
else {
header("location:index.php?error=Incorrect Username Or Password, Please Try Again");
}
mysql_close($con);
?>Code: Select all
<?
session_start();
if(!session_is_registered(adminuser)){
header("location:adminlogin.php");
}
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: