Jump to content

php login problem


mrjameer

Recommended Posts

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>



Link to comment
https://forums.phpfreaks.com/topic/25846-php-login-problem/
Share on other sites

Try adding a [code=php:0]OR DIE (mysql_error())[/code] after each MySQL function to see whether it is your MySQL queries that are at fault. For example, change [code=php:0]$conn4=mysql_connect($host,$username,$password);[/code] to be [code=php:0]$conn4=mysql_connect($host,$username,$password) OR DIE (mysql_error());[/code] and do the same for the other MySQL functions and then try to run the script again to see if you get any errors.
Link to comment
https://forums.phpfreaks.com/topic/25846-php-login-problem/#findComment-118044
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.