Advertisement
dhiforester

proses_edit_akses.php

Mar 31st, 2021
520
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.76 KB | None | 0 0
  1. <?phP
  2.     //koneksi database
  3.     include "../../Config/Connection.php";
  4.     //validasi nama lengkap tidak boleh kosong
  5.     if(empty($_POST["nama_lengkap"])){
  6.         header ("location:../../index.php?page=edit_akses&notifikasi=error1");
  7.     }else{
  8.         //Validasi email tidak boleh kosong
  9.         if(empty($_POST["email"])){
  10.             header ("location:../../index.php?page=edit_akses&notifikasi=error2");
  11.         }else{
  12.             //Validasi nomor kontak tidak boleh kosong
  13.             if(empty($_POST["no_kontak"])){
  14.                 header ("location:../../index.php?page=edit_akses&notifikasi=error3");
  15.             }else{
  16.                 //Validasi username tidak boleh kosong
  17.                 if(empty($_POST["username"])){
  18.                     header ("location:../../index.php?page=edit_akses&notifikasi=error4");
  19.                 }else{
  20.                     //Validasi password tidak boleh kosong
  21.                     if(empty($_POST["password"])){
  22.                         header ("location:../../index.php?page=edit_akses&notifikasi=error5");
  23.                     }else{
  24.                         //Validasi password tidak sama
  25.                         if($_POST["password"]!==$_POST["ulangi_password"]){
  26.                             header ("location:../../index.php?page=edit_akses&notifikasi=error6");
  27.                         }else{
  28.                             //Buat variabel agar singkat
  29.                             $id_akses=$_POST["id_akses"];
  30.                             $nama_lengkap=$_POST["nama_lengkap"];
  31.                             $email=$_POST["email"];
  32.                             $no_kontak=$_POST["no_kontak"];
  33.                             $username=$_POST["username"];
  34.                             $password=$_POST["password"];
  35.                             $level=$_POST["level"];
  36.                             //Proses update ke database
  37.                             $edit_akses = mysqli_query($conn, "UPDATE akses SET
  38.                                nama_lengkap='$nama_lengkap',
  39.                                email='$email',
  40.                                no_kontak='$no_kontak',
  41.                                username='$username',
  42.                                password='$password',
  43.                                level='$level'
  44.                            WHERE id_akses='$id_akses'") or die(mysqli_error($conn));
  45.                             if($edit_akses){
  46.                                 header ("location:../../index.php?page=akses&notifikasi=edit_akses_berhasil");
  47.                             }else{
  48.                                 header ("location:../../index.php?page=edit_akses&notifikasi=error7");
  49.                             }
  50.                         }
  51.                     }
  52.                 }
  53.             }
  54.         }
  55.     }
  56. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement