Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- include '../../model/config.php';
- include 'success.php';
- $username = $koneksi->real_escape_string($_POST['username']);
- $password = $koneksi->real_escape_string($_POST['password']);
- $query = "SELECT * FROM user WHERE username='$username'";
- $result = $koneksi->query($query);
- $count = $result->num_rows;
- //Jika User Ada
- if($count > 0){
- $cetak = $result->fetch_assoc();
- $passHash = $cetak['password'];
- $status = $cetak['status'];
- if(password_verify($password,$passHash) && $status == 0){
- $_SESSION['nama_user'] = $cetak['nama_user'];
- $_SESSION['id'] = $cetak['id_user'];
- ?>
- <script>
- $(document).ready(function(){
- swal({
- title:'Success!',
- text:'Anda Berhasil Login!',
- type:'success'
- },
- function(isConfirm){
- if(isConfirm){
- window.location=("../../view/admin.php");
- }
- });
- });
- </script>
- <?php
- }else if(password_verify($password,$passHash) && $status == 1){
- $_SESSION['nama_user'] = $cetak['nama_user'];
- $_SESSION['id'] = $cetak['id_user'];
- ?>
- <script>
- $(document).ready(function(){
- swal({
- title:'Success!',
- text:'Anda Berhasil Login!',
- type:'success'
- },
- function(isConfirm){
- if(isConfirm){
- window.location=("../../view/user.php");
- }
- });
- });
- </script>
- <?php
- }else{
- echo '<script>window.alert("Username/Password Salah!");window.location=("../../view/");</script>';
- }
- }else{
- echo '<script>window.alert("Tidak Ada Username Terdaftar!");window.location=("index.php");</script>';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement