Login system using PHP with MYSQL database




Hey guys I’d like to introduce you to this way of making money through investment with swisscoin. If you’ve not heard about swisscoin before, I recommend you …

source


48 responses to “Login system using PHP with MYSQL database”

  1. 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!!";
    }
    ?>

  2. 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

  3. 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

  4. 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

  5. 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?

  6. 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 🙁

  7. 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

  8. 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 ^^

  9. 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.

  10. 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.";

    }

    ?>

  11. 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

  12. 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?

  13. "<?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.

Leave a Reply