Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //mengkoneksian ke databese
- $connect = new mysqli("localhost", "root", "", "test");
- //menangkap data dari ajax
- $username = $connect->real_escape_string($_POST['username']);
- $email = $connect->real_escape_string($_POST['email']);
- $password = $connect->real_escape_string($_POST['password']);
- if (empty($username)) exit('input username');
- if (empty($email)) exit('input email');
- if (empty($password)) exit('input password');
- if(strlen($password) < 5) exit('password is to short');
- $hash = password_hash($password, PASSWORD_DEFAULT);
- $sql = $connect->query("SELECT * FROM user WHERE email = '$email'");
- if ($sql->num_rows > 0) {
- exit("Already Exists");
- } else {
- $connect->query("INSERT INTO user
- VALUES('','$username','$email','$hash')");
- exit("Registration Success");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement