How to Make Login Form in PHP and MySQL




Download Source Code http://www.onlineittuts.com/how-to-create-login-form-in-php.html Today We Will Learn How to Make Login Form in PHP and MySQL.

Original source


45 responses to “How to Make Login Form in PHP and MySQL”

  1. This works for those who use PHP 7.2.14

    <?php

    $host="localhost";

    $user="root";

    $password="";

    $db="demo";

    $a=mysqli_connect('localhost','root','','demo');

    mysqli_select_db($a,$db);

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

    $uname=$_POST['username'];

    $password=$_POST['password'];

    $sql="select * from loginform where User='".$uname."'AND Pass='".$password."' limit 1";

    $result=mysqli_query($a, $sql);

    if(mysqli_num_rows($result)!==0){

    echo " You Have Successfully Logged in";

    exit();

    }

    else{

    echo " You Have Entered Incorrect Password";

    exit();

    }}

    ?>

  2. How to open the php file? I tried to open it with xampp. But this error message appeared:
    Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:xampphtdocsscriptslogin.php on line 20
    You Have Entered Incorrect Password . This happens whether I put in a correct or a wron password. Thanks for help.

  3. I've done everything and got the following error :
    Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:wamp64wwwAuthAuth.php on line 10

    Anyone that can help?

  4. This is nothing just the header.php SEE BELOW FOR THE =========== LINE TO START thanks.

    <!DOCTYPE html>

    <html lang="en">

    <head>

    <title>Z-Shopping Using PHP/MySQL</title>

    <link href="css/bootstrap.css" rel="stylesheet" type="text/css" media="screen">

    <link rel="stylesheet" type="text/css" href="css/DT_bootstrap.css">

    <link href="modal/css1/bootstrap1.css" rel="stylesheet" type="text/css" media="screen">

    </head>

    <script src="modal/js1/jquery1.js" type="text/javascript"></script>

    <script src="modal/js1/bootstrap1.js" type="text/javascript"></script>

    <script src="js/jquery.js" type="text/javascript"></script>

    <script src="js/bootstrap.js" type="text/javascript"></script>

    <script type="text/javascript" charset="utf-8" language="javascript" src="js/jquery.dataTables.js"></script>

    <script type="text/javascript" charset="utf-8" language="javascript" src="js/DT_bootstrap.js"></script>

    ==================================================================

    this is the problem. see the *** below echo $row['fname']; prints out Chicken Breast All Natural Boneless Skinles

    but in the form <?php echo $row['fname']; ?>> see //////// below

    and this is a edit.php form it shows <input type="text" name="fname" required value=<?php echo $row['fname']; ?>>

    because the form is filled from the database and then you edit it. the problem is when the form is filled it only display Cheicken and not like the echo above.

    ANY HELP WOULD BE APPREXCIATED

    <?php

    include('dbconn.php');

    include ('header.php');

    $id=$_GET['id'];

    ?>

    <body>

    <div class="container">

    <div class="hero-unit-header">

    <!– end banner & menunav –>

    <center>

    <?php

    $query=mysqli_query($conn,"select * from products where id='$id'")or die(mysqli_error());

    $row=mysqli_fetch_assoc($query);

    echo $row['fname']; *************************************

    ?>

    <form method="POST">

    <hr>

    <h4>Product Information</h4>

    <hr>

    <div class="control-group">

    <label class="control-label" for="inputPassword">Product</label>

    <div class="control-label">

    <input type="text" name="fname" required value=<?php echo $row['fname']; ?>> ///////////////

    </div>

    </div>

  5. Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:xampphtdocsHTMLindex.php:8 Stack trace: #0 {main} thrown in C:xampphtdocsHTMLindex.php on line 8

    help pls

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

    Help pleaseeeeeeeeeeeee

  7. Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead) in C:xampphtdocsIMSfunction.php on line 11

    mysql_connect($host,$user,$pass);
    mysql_select_db($db);

    if (isset(['username'])){ <<line 11

    $username = $_POST['username'];
    $password = $_POST['password'];
    $sql="slect * from user where uname='".username."' AND pswd='".password."' limit 1";

    $result= mysql_query($sql);

    if (mysql_num_rows($result)==1){

    echo"sucessfully logged in";
    exit();
    }

  8. Erro fatal : Erro não detectado: Chame a função indefinida mysql_connect () em C: xampp htdocs login1 login.php: 8 Rastreio de pilha: # 0 {main} lançado em C: xampp htdocs login1 login.php na linha 8

  9. Hello sir. I have copy paste your php code and change it according to my db. After i input the email and password on login form why the page does not appear "You have successfully…." and "You have entered incorrect…."? I use notepad++

Leave a Reply