...

View Full Version : php login problem



mrjameer
11-01-2006, 08:43 PM
hi,

i have a php script for login to my web site.it works very well when i test it in localhost but when i upload it to my site it is not allowing me login.here is the code.help me to get out of it.

thanks
mrjameer

<?php
session_start();


include 'db.php';
$use=$_POST['username'];
$pwd=$_POST['password'];
$use1=sha1($use);
$pwd1=sha1($pwd);


$conn4=mysql_connect($host,$username,$password);
mysql_select_db($db,$conn4);

$sql="SELECT * FROM $table41";
$result=mysql_query($sql,$conn4);
while($newarray=mysql_fetch_array($result))
{
$username=$newarray['username'];
$password=$newarray['password'];
}

$errorMessage = '';
if (isset($_POST['username']) && isset($_POST['password'])) {

// check if the username and password combination is correct
if ($use1 === $username && $pwd1 === $password)
{
// the username and password match,
// set the session
$_SESSION['basic_is_logged_in'] = true;

// after login we move to the main page
header('Location: menu1.php');
exit;
} else {
$errorMessage = 'Sorry, wrong username / password';
}
}
?>
<html>
<head>
<title>Basic Login</title>
<style type="text/css">
html, body
{
margin: 0px;
padding: 0px;
border: 0px;
background: url(bg1.gif)repeat-x;
background-color:#8db0e5;
}
#m
{
margin-left:450px;
margin-top:150px;
}
#n
{
margin-left:50px;
margin-top:20px;
}
#o
{
margin-left:560px;
margin-top:20px;
}
</style>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php
if ($errorMessage != '') {
?>
<p align="center"><strong><font color="#990000"><?php echo $errorMessage; ?></font></strong></p>
<?php
}
?>
<form action="" method="post" name="frmLogin" id="frmLogin">
<div id="m">
<b>PLEASE ENTER USER ID / PASSWORD</b></div>
<div id="n">

<table width="400" border="1" align="center" cellpadding="2" cellspacing="2">
<tr>
<td width="150">User Id</td>
<td><input name="username" type="text" id="username" size="25"></td>
</tr>
<tr>
<td width="150">Password</td>
<td><input name="password" type="password" id="password" size="27"></td>
</tr>
<tr>
<td width="150">&nbsp;</td>
<td><input name="btnLogin" type="submit" id="btnLogin" value="Login"></td>
</tr>
</table> </div>
<div id="o"> <a href="javascript:window.close();">Exit</a></div>

</form>
</body>
</html>






mrjameer

mic2100
11-02-2006, 07:38 PM
are your usernames stored with the encryption



sha1();


if not then this may be your problem



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum