<?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")
?> 

This example is from the PHP docs page for msqli_select: Click Here

<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "test");

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

/* return name of current default database */
if ($result = mysqli_query($link, "SELECT DATABASE()")) {
    $row = mysqli_fetch_row($result);
    printf("Default database is %s.\n", $row[0]);
    mysqli_free_result($result);
}

Compare that to yours and you'll see some differences which explain what you've done wrong.

This article has been dead for over six months. Start a new discussion instead.