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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.