48 thoughts on “Login system using PHP with MYSQL database

  • April 24, 2017 at 23:02
    Permalink

    PLEASE help me!!

    $result = mysql_query("select * from users where user ='$username' and pass = '$pass'")
    You created $user abd then you query it using $username

    <?php
    $username = $_POST['user'];
    $password = $_POST['pass'];

    $username = stripcslashes($username);
    $password = stripcslashes($password);
    $username = mysql_real_escape_string($username);
    $password = mysql_real_escape_string($password);

    mysql_connect("localhost", "root", "");
    mysql_select_db("login");

    $result = mysql_query("select * from users where username = '$username' and password = '$password'")
    or die("Failed to query db " . mysql_error());
    $row = mysql_fetch_array($result);
    if($row['username'] == $username && $row['password'] == $password){
    echo "LOgin succes!!! Welcome " . $row['username'];
    }
    else{
    echo " failed to login!!";
    }
    ?>

  • April 24, 2017 at 23:02
    Permalink

    Notice: Undefined index: mp in C:UsersexamenDocumentsEasyPHP-5.3.9wwwtcmplusloginserv.php on line 3
    failed to query databaseAucune base n'a été sélectionnée

  • April 24, 2017 at 23:02
    Permalink

    i tried to remove the * in line 20 but this is still the result, how can i fix this?
    Parse error: syntax error, unexpected '*' in C:wampwwwloginprocess.php on line 20

  • April 24, 2017 at 23:02
    Permalink

    Fatal error: Uncaught Error: Call to undefined function mysql_connect() in E:xamphtdocsphppractise.php:6 Stack trace: #0 {main} thrown in E:xamphtdocsphppractise.php on line 6

    plzzzzzzzzzzz help me why its arise the error

  • April 24, 2017 at 23:02
    Permalink

    somebody can help me?
    <?php
     // Valores de login.php
     $username=$_POST['user'];
     $password=$_POST['pass']; // Prevenir otra trayectoria de mysql $username=stripcslashes($username);
     $password=stripcslashes($password);
     $username=mysqli_real_escape_string($username);
     $password=mysqli_real_escape_string($password); // Conexion
     mysqli_connect("localhost","root", "");
     mysqli_select_db("login"); // Registro del usuario
     $result= mysqli_query("select * from users where username = '$username' and password = '$password'")
       or die("Acceso fallido al registo" .mysqli_error());
     $row= mysqli_fetch_array()($result);
     if($row['username'] == $username && $row['password'] == $password && ("" !== $username || "" !== $password)) {
      echo "Login Success! Welcome, ".$row['username'];
     } else {
      echo "Failed to Login!";
     }?>

    Warning: mysqli_real_escape_string() expects exactly 2 parameters, 1 given in C:wamp64wwwLoginprocess.php on line 10

    ( ! ) Warning: mysqli_query() expects at least 2 parameters, 1 given in C:wamp64wwwLoginprocess.php on line 18

  • April 24, 2017 at 23:02
    Permalink

    When I press login button it shows output with a notice.

    Notice: Undefined variable: POST in C:xampphtdocsphpprocess.php on line 2
    Notice: Undefined variable: POST in C:xampphtdocsphpprocess.php on line 3

    Here is my process.php:

    $username = $POST['user'];
    $password = $POST['pass'];

    Also note that login.php contains same id as in process.php

  • April 24, 2017 at 23:02
    Permalink

    Warning: mysql_connect(): php_network_getaddresses: getaddrinfo failed: ������� �������� �����������. in C:xampphtdocsloginprocess.php on line 10Warning: mysql_connect(): php_network_getaddresses: getaddrinfo failed: ������� �������� �����������. in C:xampphtdocsloginprocess.php on line 10
    Failed to query databaseNo database selected

    This is my problem what can I do?

  • April 24, 2017 at 23:02
    Permalink

    when i add user type, after i logged in, this error shows: mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean

    this is my code in php:

    $type=mysql_real_escape_string($_POST['type']);
    $sql="SELECT username, password, user_type from users WHERE username='$username', password='$password' and user_type = '$type'";
    $result = mysqli_query($db,$sql);

    if(mysqli_num_rows($result) == 1)
    {
    // $_SESSION['message']="You are now Loggged In";
    $_SESSION['admin']= $type . " " . $username . "!";
    header("location:home.php");
    }
    else
    {
    echo "<p><center><font color = red>Incorrect username, password or user type!";
    }
    }

    code in html:

    <label><h3>User Type:</h3></label>
    <select name = "type" id = "comboBox">
    <option value = ""></option>
    <option value = "Admin"> Admin </option>
    <option value = "Cashier"> Cashier </option>
    </select>

    help pls 🙁

  • April 24, 2017 at 23:02
    Permalink

    Build this and it works

    <?php

    if(isset($_POST['btnInloggen'])){

    $username = $_POST['txtGebruikersnaam'];
    $password = $_POST['txtWachtwoord'];

    $username = stripcslashes($username);
    $password = stripcslashes($password);

    $result = mysqli_query($dbcon,"select * from inloggen where gebruikersnaam = '$username' and wachtwoord = '$password'")
    or die("failed to query database". mysqli_error($dbcon));
    //CHECK OF AANTAL ROWS MEER IS DAN

    $row= mysqli_fetch_array($result);
    if ($row['gebruikersnaam'] == $username && $row['wachtwoord'] == $password){
    echo "inloggen gelukt";
    }
    else {
    echo "failed";
    }

    }
    ?>

    greetings php GOD

  • April 24, 2017 at 23:02
    Permalink

    Thank you! You exactly showed what I've been looking for after hours of searching! I went to almost every forum there is and no one even tried to explain this exact, "$result"-"$row" technique and the comparison from database to php-variables, to me. Very nice. You deserve a thumbs up ^^

  • April 24, 2017 at 23:02
    Permalink

    My process.php just comes out like normal text when i log in.

    <?php
    // Get values passe from form in login.php file
    $username = $POST['username'];
    $password = $POST['password'];

    // to prevent mysql injection
    $username = stripcslashes($username);
    $password = stripcslashes($password);
    $username = mysql_real_escape_string($username);
    $password = mysql_real_escape_string($password);

    // connect to the server and select database
    mysql_connect("localhost", "root", "");
    mysql_select_db("login");

    // Query the database for user
    $result = mysql_query("select * from users where username = '$username and password = '$password'")
    or die("Failed to query database".mysqlerror());
    $row = mysql_fetch_array($result);
    if ($row['username'] == $username && $row['password'] == $password) {
    echo "Login success! Welcome ".$row['username'];
    } else {
    echo "Failed to login!";
    }
    ?>

    That's my code and also what i see when i press the login button.

  • April 24, 2017 at 23:02
    Permalink

    i am getting this type of error,can you please suggest me to correct these error.
    Parse error: syntax error, unexpected 'echo' (T_ECHO) in C:xampphtdocsloginprocess.php on line 18

  • April 24, 2017 at 23:02
    Permalink

    why won't this work?

    <?php

    $username = $POST['username'];
    $password = $POST['password'];

    $username = stripcslashes($username);
    $password = stripcslashes($password);

    $username = mysql_real_escape_string($username);
    $password = mysql_real_escape_string($password);

    mysql_connect("localhost", "root", "");
    mysql_select_db("loginandregister");

    $result = mysql_query("select * from users where username = '$username' and password = '$password'")
    or die("Failed to query the Database".mysql_error());
    $row = mysql_fetch_array($result)

    if ($row['username'] == $username && $row['password'] == $password ){
    echo "Login sucess! Welcome ".$row['username'];

    } else {
    echo "Login failed.";

    }

    ?>

  • April 24, 2017 at 23:02
    Permalink

    facing a problem sir can u suggest me…. error
    Fatal error: Uncaught Error: Call to undefined function mysql_real_escape_string() in C:xampphtdocsgym css3 html5process.php:10 Stack trace: #0 {main} thrown in C:xampphtdocsgym css3 html5process.php on line 10

  • April 24, 2017 at 23:02
    Permalink

    you should have entered wrong password or wrong username or keep the fields empty to show that your program is working properly on every parameter

  • April 24, 2017 at 23:02
    Permalink

    I got "Fatal error: Uncaught Error: Call to undefined function mysql_real_escape_string() in /storage/h3/217/646217/public_html/process.php:9 Stack trace: #0 {main} thrown in /storage/h3/217/646217/public_html/process.php on line 9" when submitting form. What's wrong with the code?

  • April 24, 2017 at 23:02
    Permalink

    "<?php
    $localhost = "localhost";
    $dbuser = "admin";
    $dbpass = "";
    $dbname = "test";

    $connect = mysql_connect($localhost, $dbuser, $dbpass);
    mysql_select_db("$dbname", $connect);

    ?>"
    Make config.php file it is easier (include"config.php") at every page you make that need connection.

  • April 24, 2017 at 23:02
    Permalink

    'Screams internally' -me as a professional front end dev watching a back-end developer create html/css.

    Just kidding, thank you for taking the time to make this video, it's been helpful.

Leave a Reply