0
 <?php
session_start();
$username=$_POST['username'];
$password=$_POST['password'];
if($username&&$password)
{

mysqli_select_db("user",$myconnection) or die("couldn't find db");
$sqlcommand="SELECT * FROM users where username='$username'";
$query= mysqli_query($myconnection,$sqlcommand);

$numrows= mysqli_num_rows($query);
if($numrows!==0)
{
    while($row= mysqli_fetch_assoc($query))
    {
        $dbusername=$row['username'];
        $dbpassword=$row['password'];
    }

    if($username==$dbusername&&md5($password)==$dbpassword)
    {
        echo "you are logged in!";
        $_SESSION['username']=$username;
    }
    else
        echo"your password is incorrect!";

}
else
    die("that user doesn't exits");
}
else
    die("please enter your username and password")
?> 

Edited by Nospor Kumam: plz help i'm new to this :Warning: mysqli_select_db() expects exactly 2 parameters, 1 given in C:\xampp\htdocs\register.php on line 9

2
Contributors
2
Replies
10
Views
1 Year
Discussion Span
Last Post by Nospor Kumam
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.