Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

login error

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

login error

Postby BandanaChaudhury » Tue Jan 22, 2013 11:24 pm

i an having a login form

<?php
error_reporting(0);
$adminpwd = md5($_POST['adminpwd']);
$enter = $_POST['enter'];
$servername = "localhost";
$username = "root";
$password = "";
if ($enter)
{
$connect = mysql_connect($servername, $username, $password) or die(mysql_error());
mysql_select_db("bctravels") or die(mysql_error());
$query = mysql_query("SELECT admin_pwd FROM admin");
$numrows = mysql_num_rows($query);
if($numrows!=0)
{
while ($rows = mysql_fetch_assoc($query))
{
$db_admin_pwd = $rows['admin_pwd'];
}
if ($adminpwd==$db_admin_pwd)
{
session_register("adminpwd");
header("location:admin_home.php");
}
else
echo "/////";
}
else
echo "...";
}
?>
<html>
<head>
<link href="../admin/admin.css" rel="stylesheet" type="text/css" />
<title>Administration password check</title>
</head>
<body>
<center><div>
<h3>You're the Administrator</h3>
<br/>
<form action='admin_pwd.php' method='POST'>
Enter Admin Password,
<br/>
<input type='password' name='adminpwd'>
<br/>
<input type='submit' name='enter' value='enter'>
</form>
</div></center>
</body>
</html>

I dont know why the $adminpwd and $db_admin_pwd doesnot match,
is there any error in my coding,
please help. :help: :help: :help:
BandanaChaudhury
New php-forum User
New php-forum User
 
Posts: 22
Joined: Fri Jun 22, 2012 9:14 am

Re: login error

Postby simplypixie » Wed Jan 23, 2013 12:47 am

Firstly, are you sure the password in the database is encoded with MD5? Why not echo out the posted password and the password you are getting from your query and double check they do match.

On a second note, why on earth would you want to store a password in your session - very insecure?
User avatar
simplypixie
php-forum Active User
php-forum Active User
 
Posts: 300
Joined: Sun Dec 11, 2011 12:51 am
Location: Shrewsbury, Shropshire


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.