Advertisement
dhiforester

proses_tambah_akses.php

Mar 31st, 2021
535
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.93 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=tambah_akses&notifikasi=error1");
  7.     }else{
  8.         //Validasi email tidak boleh kosong
  9.         if(empty($_POST["email"])){
  10.             header ("location:../../index.php?page=tambah_akses&notifikasi=error2");
  11.         }else{
  12.             //Validasi nomor kontak tidak boleh kosong
  13.             if(empty($_POST["no_kontak"])){
  14.                 header ("location:../../index.php?page=tambah_akses&notifikasi=error3");
  15.             }else{
  16.                 //Validasi username tidak boleh kosong
  17.                 if(empty($_POST["username"])){
  18.                     header ("location:../../index.php?page=tambah_akses&notifikasi=error4");
  19.                 }else{
  20.                     //Validasi password tidak boleh kosong
  21.                     if(empty($_POST["password"])){
  22.                         header ("location:../../index.php?page=tambah_akses&notifikasi=error5");
  23.                     }else{
  24.                         //Validasi password tidak sama
  25.                         if($_POST["password"]!==$_POST["ulangi_password"]){
  26.                             header ("location:../../index.php?page=tambah_akses&notifikasi=error6");
  27.                         }else{
  28.                             //Buat variabel agar singkat
  29.                             $nama_lengkap=$_POST["nama_lengkap"];
  30.                             $email=$_POST["email"];
  31.                             $no_kontak=$_POST["no_kontak"];
  32.                             $username=$_POST["username"];
  33.                             $password=$_POST["password"];
  34.                             $level=$_POST["level"];
  35.                             //Proses Submit ke database
  36.                             $entry="INSERT INTO akses (
  37.                                nama_lengkap,
  38.                                email,
  39.                                no_kontak,
  40.                                username,
  41.                                password,
  42.                                level
  43.                            ) VALUES (
  44.                                '$nama_lengkap',
  45.                                '$email',
  46.                                '$no_kontak',
  47.                                '$username',
  48.                                '$password',
  49.                                '$level'
  50.                            )";
  51.                             $hasil=mysqli_query($conn, $entry);
  52.                             if($hasil){
  53.                                 header ("location:../../index.php?page=akses&notifikasi=tambah_akses_berhasil");
  54.                             }else{
  55.                                 header ("location:../../index.php?page=tambah_akses&notifikasi=error7");
  56.                             }
  57.                         }
  58.                     }
  59.                 }
  60.             }
  61.         }
  62.     }
  63. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement