Jump to content

PHP login


youri

Recommended Posts

Hello,

 

I have a login. Everything works correct, except the password check. I can fill in anything and I Log in. Can anyone help me to check this out?

 

Thanks in advance!

 

<?php

session_start();

$username = ($_POST['username']);
$password = ($_POST['password']);

if ($username&&$password)
{

$connect=mysql_connect("localhost", "forum", "") or die("Could not connect.");
mysql_select_db("name") or die("Couldn't find db");

$query = mysql_query("SELECT * FROM users WHERE username='$username'");

$numrows = mysql_num_rows($query);

if ($numrows!=0)
    {
        while ($row = mysql_fetch_assoc($query))  
        {
             $dbusername = $row['username'];  
             $dbpassword = $row['password'];        
        }
       
        // check to see if they match
        if ($username==$dbusername&&sha1(md5($password)==$dbpassword))  
        {
         header("location:homee.php");
         $_SESSION ['username']=$username;    
         exit;
        }
                        else
            echo("Incorrect password!");
               include("index.php");
               exit;        
    }    
else
    echo("that user doesn't exist");  
    include("index.php");
    exit;
   

}    
else
   echo("Please enter username and password ");
   include("index.php");
   exit;

?>

Link to comment
Share on other sites

if that still does not work, try to echo out both the password that is stored in your database, $row['password'], and the encrypted user given password,  sha1(md5($password), to make sure you are getting the results that you want from your encryption

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.