Advertisement
toobi

login php

Oct 5th, 2016
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.57 KB | None | 0 0
  1. //untuk login
  2.     function cek_data($nama,$pass){
  3.         global $link;
  4.  
  5.             //mencegah sql injection
  6.             $nama = mysqli_real_escape_string($link, $nama);
  7.             $pass = mysqli_real_escape_string($link, $pass);
  8.  
  9.             $query = "SELECT password FROM users WHERE username='$nama'";
  10.             $result = mysqli_query($link, $query);
  11.             $hash   = mysqli_fetch_assoc($result)['password'];
  12.  
  13.             print_r($hash);
  14.  
  15.             // while ($data = mysqli_fetch_assoc($result)) {
  16.             //  echo $data['password'];
  17.             // }
  18.  
  19.         if( password_verify($pass, $hash) ){
  20.             die('berhasil');
  21.         }else{
  22.             die('gagal');
  23.         }
  24.  
  25.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement