Advertisement
oimtrust

bio_add_crud-pdo-oop

Dec 28th, 2016
2,137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.94 KB | None | 0 0
  1. <?php
  2.     require_once 'app/model/class.bio.php';
  3.  
  4.     $auth_bio = new Biodata();
  5.  
  6.     if (isset($_POST['btn-save'])) {
  7.         $nama   = strip_tags($_POST['nama']);
  8.         $phone  = strip_tags($_POST['phone']);
  9.         $alamat = strip_tags($_POST['alamat']);
  10.  
  11.         if ($nama == "") {
  12.             $error[]    = "Nama masih kosong!";
  13.         }
  14.         elseif ($phone == "") {
  15.             $error[]    = "Nomor harus di isi. Bila tidak punya nomor cukup di isi NOL saja!";
  16.         }
  17.         elseif (strlen($phone) > 14) {
  18.             $error[]    = "Nomor telepon anda tidak valid!";
  19.         }
  20.         elseif ($alamat == "") {
  21.             $error[]    = "Alamat masih kosong!";
  22.         }
  23.         else {
  24.             try {
  25.                 if ($auth_bio->insertBio($nama,$phone,$alamat)) {
  26.                     $auth_bio->redirect('bio-add.php?saved');
  27.                 }
  28.             } catch (PDOException $e) {
  29.                 echo $e->getMessage();
  30.             }
  31.         }
  32.     }
  33.  
  34.     //Untuk menampilkan view
  35.     include 'app/view/header.php';
  36.     include 'app/view/menu.php';
  37.     include 'app/view/bio-add.blade.php';
  38.     include 'app/view/footer.php';
  39.  ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement