Advertisement
Guest User

register_user

a guest
Oct 15th, 2019
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. $con = mysqli_connect(HOST, USER, PASSWORD, DB) or die("Unable to Connect");
  2. $userName = $_GET['user_name'];
  3. $userID = $_GET['user_id'];
  4. $userPhone = $_GET['user_phone'];
  5. $userPassword = $_GET['user_password'];
  6. if($userName == '' || $userID == '' || $userPassword == ''){
  7. echo 'User Name, ID or Password can not be empty';
  8. }else{
  9. $query = "select * from users where email = '$userID'";
  10. $recordExists = mysqli_fetch_array(mysqli_query($con, $query));
  11. if(isset($recordExists)){
  12. echo 'User already exists';
  13. }else{
  14. $query = "INSERT INTO users (name, email, phone, password) VALUES ('$userName', '$userID', '$userPhone', '$userPassword')";
  15. if(mysqli_query($con, $query)){
  16. echo 'User registered successfully';
  17. }else{
  18. echo 'oops! please try again!';
  19. }
  20. }
  21. mysqli_close($con);
  22. }
  23. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement