Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Aug 2006
    Posts
    133
    Thanks
    0
    Thanked 0 Times in 0 Posts

    php login problem

    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

  • #2
    Regular Coder mic2100's Avatar
    Join Date
    Feb 2006
    Location
    Scunthorpe
    Posts
    562
    Thanks
    15
    Thanked 28 Times in 27 Posts
    are your usernames stored with the encryption

    PHP Code:
    sha1(); 
    if not then this may be your problem


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •