Advertisement
Guest User

proses

a guest
Jun 28th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. <?php
  2. //mengkoneksian ke databese
  3. $connect = new mysqli("localhost", "root", "", "test");
  4.  
  5. //menangkap data dari ajax
  6. $username = $connect->real_escape_string($_POST['username']);
  7. $email = $connect->real_escape_string($_POST['email']);
  8. $password = $connect->real_escape_string($_POST['password']);
  9.  
  10. if (empty($username)) exit('input username');
  11. if (empty($email)) exit('input email');
  12. if (empty($password)) exit('input password');
  13. if(strlen($password) < 5) exit('password is to short');
  14.  
  15. $hash = password_hash($password, PASSWORD_DEFAULT);
  16. $sql = $connect->query("SELECT * FROM user WHERE email = '$email'");
  17. if ($sql->num_rows > 0) {
  18. exit("Already Exists");
  19. } else {
  20. $connect->query("INSERT INTO user
  21. VALUES('','$username','$email','$hash')");
  22. exit("Registration Success");
  23. }
  24.  
  25. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement