SHARE
TWEET

Untitled

a guest May 24th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $name = $_POST['name'];
  4.  
  5. $email = $_POST['email'];
  6.  
  7. $newsletter = $_POST['newsletter'];
  8.  
  9. $gender = $_POST['gender'];
  10.  
  11.  
  12.  
  13. if (!empty($name) || !empty($email) || !empty($newsletter) || !empty($gender)) {
  14.  
  15.     $host = "localhost";
  16.  
  17.     $dbUsername = "root";
  18.  
  19.     $dbPassword = "";
  20.  
  21.     $dbname = "website";
  22.  
  23.    
  24.  
  25.     $conn = new mysqli($host, $dbUsername, $dbPassword, $dbname);
  26.  
  27.    
  28.  
  29.     if (mysqli_connect_error()) {
  30.  
  31.         die('Connect Error('. mysqli_connect_errno().')'. mysqli_connect_error());
  32.  
  33.     } else {
  34.  
  35.             $SELECT = "SELECT email From register Where email = ? Limit 1";
  36.  
  37.             $INSERT = "INSERT Into register (name, email, newsletter, gender) values(?, ?, ?, ?)";
  38.  
  39.            
  40.  
  41.             $stmt = $conn->prepare($SELECT);
  42.  
  43.             $stmt->bind_param("s", $email);
  44.  
  45.             $stmt->execute();
  46.  
  47.             $stmt->bind_result($email);
  48.  
  49.             $stmt->store_result();
  50.  
  51.             $rnum = $stmt->num_rows;
  52.  
  53.            
  54.  
  55.             if ($rnum==0) {
  56.  
  57.                 $stmt->close();
  58.  
  59.                
  60.  
  61.                 $stmt-> $conn->prepare($INSERT);
  62.  
  63.                 $stmt->bind_param("ssis", $name, $email, $newsletter, $gender);
  64.  
  65.                 $stmt->execute();
  66.  
  67.                 echo New "record inserted successfullys";
  68.  
  69.             } else {
  70.  
  71.              echo "Allready registerd!"    
  72.  
  73.             }
  74.  
  75.             $stmt->close();
  76.  
  77.             $conn->close();
  78.  
  79.     }
  80.  
  81.    
  82.  
  83. } else{
  84.  
  85.     echo "All fields are required!";
  86.  
  87.     die();
  88.  
  89. }
  90.  
  91. ?>
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