Advertisement
Guest User

php

a guest
Feb 29th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.90 KB | None | 0 0
  1. connect.php -> buat actifin myadmin database di localhost:
  2. <?php
  3.  
  4.     $conn = mysqli_connect("localhost","root","1234");
  5.  
  6.     if($conn -> connect_error){
  7.         die("connection failed: ".$conn -> connect_error);
  8.     }else{
  9.         echo "connection successful";
  10.     }
  11.  
  12.  
  13.  ?>
  14.  
  15. doLogin.php -> buat fungsi login form:
  16.  
  17. <?php
  18. include("connect.php");
  19.  
  20.     $user=$_POST["txtuser"];
  21.     $pass=$_POST["txtpass"];
  22.  
  23.     if($user == ""){
  24.         header("Location:login.php?err=Username tidak boleh kosong");
  25.     }else if($pass == ""){
  26.         header("Location:login.php?err=Password tidak boleh kosong");
  27.    
  28.     }else{
  29.         $query="SELECT * FROM MsMember WHERE username = '$user' AND password='$pass'";               
  30.         $result = mysqli_query($conn,$query);
  31.  
  32.         if(mysqli_num_rows($result) <= 0){
  33.             header("Location:login.php?err=login failed");
  34.  
  35.         }else{
  36.             header("Location:login.php?err=Login Succes, Welcome, $user");
  37.            
  38.         }
  39.  
  40.     }
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement