Advertisement
Guest User

action_page

a guest
May 29th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.88 KB | None | 0 0
  1. <?php
  2. session_start(); // Right at the top of your script
  3. ?>
  4.  
  5. <?php
  6.  
  7. include("config.php");
  8.  
  9. // cek apakah tombol daftar sudah diklik atau blum?
  10. if(isset($_POST['regist'])){
  11.  
  12.     // ambil data dari formulir
  13.     $username = $_POST['username'];
  14.     $password = $_POST['password'];
  15.     $city = $_POST['city'];
  16.     $_SESSION['username']=$username;
  17.     $_SESSION['logged']=true;
  18.     // buat query
  19.     $sql = "INSERT INTO registrasi (username, password, city) VALUE ('$username', '$password', '$city')";
  20.     $query = mysqli_query($db, $sql);
  21.  
  22.     // apakah query simpan berhasil?
  23.     if( $query ) {
  24.         // kalau berhasil alihkan ke halaman index.php dengan status=sukses
  25.         header('Location: pwebuts2.php');
  26.     } else {
  27.         // kalau gagal alihkan ke halaman indek.php dengan status=gagal
  28.         header('Location: regispweb.php?status=gagal');
  29.     }
  30.  
  31. }
  32.  
  33. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement