Login Form Tidak Bisa untuk Login

Discussion in 'Desain Web dan Programming' started by mas.satriyo, 12 Dec 2014.

Thread Status:
Not open for further replies.
  1. mas.satriyo

    mas.satriyo Expert 2.0

    Messages:
    950
    Likes Received:
    138
    Trophy Points:
    43
    saya iseng2 coba bikin cms
    comot dari beberapa template admin html5 gratis + native php
    layout panel udah hampir jadi, baru 'ngeh' kalo belum punya login form

    ini coba2 bikin, kok tiap buat login malah mental ya..
    display error =1 yg artinya username & password tidak di input di form
    padahal sudah di input

    versi hidupnya ada di
    Code:
    maswibowo.web.id/login.php
    ini source code nya
    ==> login form (login.php)
    Code:
    <!DOCTYPE html>
    <html lang="en">
    <head>
    
    <title>Login Page</title>
    <!-- Bootstrap core CSS -->
    <link href="assets/css/bootstrap.css" rel="stylesheet">
    <!--external css-->
    <link href="assets/font-awesome/css/font-awesome.css" rel="stylesheet" />
    <!-- Custom styles for this template -->
    <link href="assets/css/style.css" rel="stylesheet">
    <link href="assets/css/style-responsive.css" rel="stylesheet">
    </head>
    
    <body>
    <!--Begin PHP Warning-->
    <?php
    if (!empty($_GET['error'])) {
    if ($_GET['error'] == 1) {
    echo "Username dan Password Wajib Diisi !";
    } else if ($_GET['error'] == 2) {
    echo "Username Wajib Diisi !";
    } else if ($_GET['error'] == 3) {
    echo "Password Wajib Diisi !";
    } else if ($_GET['error'] == 4) {
    echo "Username dan Password Tidak Terdaftar";
    }
    }
    ?>
    <!--End of PHP Warning-->
    <div id="login-page">
    <div class="container">
    <form class="form-login" action="configs/authenticate.php" method="post">
    <h2 class="form-login-heading">sign in now</h2>
    <div class="login-wrap">
    <input type="text" name="username" class="form-control" placeholder="UserID" autofocus>
    <br>
    <input type="password" name="password" class="form-control" placeholder="Password">
    <br>
    <button class="btn btn-theme btn-block" type="submit"><i class="fa fa-lock"></i> SIGN IN</button>
    <hr>
    </div>
    <!-- Modal -->
    <div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="myModal" class="modal fade">
    <div class="modal-dialog">
    <div class="modal-content">
    <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h4 class="modal-title">Forgot Password ?</h4>
    </div>
    <div class="modal-body">
    <p>Enter your e-mail address below to reset your password.</p>
    <input type="text" placeholder="Email" autocomplete="off" class="form-control placeholder-no-fix">
    </div>
    <div class="modal-footer">
    <button data-dismiss="modal" class="btn btn-default" type="button">Cancel</button>
    <button class="btn btn-theme" type="button">Submit</button>
    </div>
    </div>
    </div>
    </div>
    <!-- modal -->
    </form>
    </div>
    </div>
    [removed][removed]
    [removed][removed]
    <!--BACKSTRETCH-->
    <!-- You can use an image of whatever size. This script will stretch to fit in any screen size.-->
    [removed][removed]
    <!--script>
    $.backstretch("assets/img/login-bg.jpg", {speed: 500});
    [removed]
    </html>
    
    ==> otentikasi login nya (authenticate.php)
    Code:
    <?php
    require 'connectdb.php';
    //Connection Check
    $con = mysqli_connect($dbserver,$dbuser,$dbpass,$dbname);
    if(mysqli_connect_errno())
    {
    echo "Database connection failed :" . mysqli_connect_error();
    }
    session_start();
    $name = ( isset( $_POST["username"] ) && $_POST['username'] != '' ) ? $_POST['username'] : '';
    $password = ( isset( $_POST["password"] ) && $_POST["password"] != '' ) ? $_POST["password"] : '';
    //empty check
    if (empty($name) && empty($password)) {
    //empty username and password
    header('location:/login.php?error=1');
    break;
    } else if (empty($name)) {
    //empty username
    header('location:/login.php?error=2');
    break;
    } else if (empty($password)) {
    //empty password
    header('location:/login.php?error=3');
    break;
    }
    $check = "SELECT * FROM login WHERE username = '".$name."' AND password = '".$password."'" ;
    $querycheck=mysqli_query($con,$check);
    if (mysqli_num_rows($querycheck) > 0) {
    $_SESSION['name'] = $name;
    header('location:/index.php');
    } else if(mysqli_num_rows($querycheck)==0) {
    header('location:/login.php?error=4');
    }
    ?>
    
    trims banyak atas jawaban yg diberikan
     
  2. WidigdoNetwork

    WidigdoNetwork Apprentice 1.0

    Messages:
    351
    Likes Received:
    64
    Trophy Points:
    28
    Coba yang ini
    Code:
    $check = "SELECT * FROM login WHERE username = '".$name."' AND password = '".$password."'" ;
    Diganti sama
    Code:
    $check = "SELECT * FROM login WHERE username='$name' AND password='$password'";
     
Loading...
Thread Status:
Not open for further replies.

Share This Page

Loading...