SHARE
TWEET

Untitled

a guest Dec 13th, 2016 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. include 'core/init.php'; //connect ke database
  3. #// tambahan script 24 november 2016
  4. if (isset($_POST['submit'])){
  5.     $name = $_POST['name'];
  6.     $username= $_POST['username'];
  7.     $email= $_POST['email'];
  8.     $phone = $_POST['phone'];
  9.     $password = md5($_POST['password']);
  10.     $interest1 = $_POST['interest1'];
  11.     $interest2 = $_POST['interest2'];
  12.  
  13.  # Validasi form kosong
  14.     if((!empty($name)) && (!empty($username)) && (!empty($email)) && (!empty($phone)) && (!empty($password)))
  15.  
  16.     {
  17.  
  18.     $query = "INSERT INTO user (nama, username, nomor_telefon, email, password, interest1, interest2) VALUES ('$name', '$username', '$phone', '$email', '$password', '$interest1', '$interest2')";
  19.     mysqli_query($connection, $query);
  20.     header("location: index.php");
  21.  
  22.     #untuk cek interest 1
  23.      $mySql = "SELECT * from user,restoran where user.interest1 = restoran.id_kategori";
  24.   $myQry = mysqli_query($connection, $mySql) ;
  25.   while ($myData = mysqli_fetch_array($myQry))
  26.    
  27.   {
  28.    
  29.     $id_user = $myData['id_user'];
  30.     $id_kategori = $myData['id_kategori'];
  31.     $interest1 = $myData['interest1'];
  32.     $interest2 = $myData['interest2'];
  33.     $id_restoran = $myData['id_restoran'];
  34.  
  35.    
  36.  
  37.     if($interest1=$id_kategori){
  38.         $query = "INSERT INTO nilai (id_user, id_kategori, id_restoran, nilai, koef ) VALUES ('$id_user', '$interest1', '$id_restoran', '100', '0.448276')";
  39.     mysqli_query($connection, $query);}
  40.     else{}
  41.     }
  42.    
  43.    
  44.     #untuk cek interest 2
  45.     $mySql = "SELECT * from user,restoran where user.interest2 = restoran.id_kategori";
  46.   $myQry = mysqli_query($connection, $mySql) ;
  47.   while ($myData = mysqli_fetch_array($myQry))
  48.    
  49.   {
  50.      
  51.     $id_user = $myData['id_user'];
  52.     $id_kategori = $myData['id_kategori'];
  53.     $interest1 = $myData['interest1'];
  54.     $interest2 = $myData['interest2'];
  55.     $id_restoran = $myData['id_restoran'];
  56.  
  57.  
  58.  
  59.     if($interest2=$id_kategori){
  60.         $query = "INSERT INTO nilai (id_user, id_kategori, id_restoran, nilai, koef ) VALUES ('$id_user', '$interest2', '$id_restoran', '80', '0.448276')";
  61.     mysqli_query($connection, $query);}
  62.     else{}
  63.     }
  64.  
  65.     #untuk cek selain interest
  66.     $mySql = "SELECT * from user,restoran where user.interest2 != restoran.id_kategori and user.interest1 != restoran.id_kategori ";
  67.   $myQry = mysqli_query($connection, $mySql) ;
  68.   while ($myData = mysqli_fetch_array($myQry)){
  69.  
  70.     $id_user = $myData['id_user'];
  71.     $id_kategori = $myData['id_kategori'];
  72.     $interest1 = $myData['interest1'];
  73.     $interest2 = $myData['interest2'];
  74.     $id_restoran = $myData['id_restoran'];
  75.  
  76.    
  77.  
  78.     $query = "INSERT INTO nilai (id_user, id_kategori, id_restoran, nilai, koef ) VALUES ('$id_user', '', '$id_restoran', '0', '0.448276')";
  79.     mysqli_query($connection, $query);
  80.  
  81.   }
  82.      }
  83.      else{print "<script>alert('Maaf, tidak boleh ada field yang kosong !') ;
  84.     javascript:history.go(-1);</script>";}
  85.  
  86. } // akhir tambahan script php (untuk login).
  87. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top