34 thoughts on “how to create login page in php with mysql

  1. if you're trying to do all this through command line in linux, you need to change mysqli_connect to another user. Root is blocked and it won't work. Create another user in sql and give it all privilleges

  2. dear sir i have a create a problem.
    that login page
    my database name and table name defint but login page show EORRE messages.
    Username of Password is Invalid.
    pl. reply soon.
    pl. check my code

    $error=''; //Variable to Store error message;
    if(empty($_POST['username']) || empty($_POST['password'])){
    $error = "Username or Password is Invalid";
    //Define $username and $password
    //Establishing Connection with server by passing server_name, user_id and pass as a patameter
    $conn = mysqli_connect("localhost", "luckyprajapat", "");
    //Selecting Database
    $db = mysqli_select_db($conn, "jaishree");
    //sql query to fetch information of registerd user and finds user match.
    $query = mysqli_query($conn, "SELECT * FROM lokesh WHERE password='$password' AND username='$username'");

    $rows = mysqli_num_rows($query);
    if($rows == 1){
    header("Location: shree.php"); // Redirecting to other page
    $error = "Username of Password is Invalid";
    mysqli_close($conn); // Closing connection


    my sql filed

    my sql con.

    database name jaishree
    table name lokesh

Leave a Reply to Jojo jaja Cancel reply

Your email address will not be published. Required fields are marked *