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
https://forums.phpfreaks.com/topic/238867-php-login/
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.