Advertisement
Guest User

Untitled

a guest
Jul 16th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.85 KB | None | 0 0
  1. <?php
  2. if(isset($_POST['simpan'])){
  3.  $user = $_POST['user'];
  4.  $pass = md5($_POST['pass']);
  5.  
  6.  $conn = mysqli_connect('localhost', 'root', '', 'db_aset');
  7.   if(mysqli_connect_errno()){
  8.    echo "Koneksi Ke Server Gagal";
  9.    exit();
  10.   }
  11.  
  12.  $sql="select * from user where username='$user' AND password='$pass'";
  13.     $result=mysqli_query($conn, $sql);
  14.     $num_rows=mysqli_num_rows($result);
  15.     $row=mysqli_fetch_row($result);
  16.     if($num_rows>0){
  17.         session_start();
  18.         $tipe=mysqli_fetch_row(mysqli_query($conn,"select * from user where username='$user' AND password='$pass'"));
  19.         $_SESSION['kosong']=$tipe[0];
  20.         echo "<script>location='indexx.php';</script>";
  21.     } else {
  22.         echo "<script>alert('Username atau Password yang anda masukkan salah!');</script>";
  23.         echo "<script>location='index.php';</script>";
  24.     }
  25. }
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement