Guest User

Untitled

a guest
Jan 14th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. <?php
  2. $user_name = $_POST['user_name'];
  3. $user_password = $_POST['user_password'];
  4. $phone_number = $_POST['phone_number'];
  5. $user_email = $_POST['user_email'];
  6. if (!empty($user_name) || !empty($user_password) || !empty($phone_number) || !empty($user_email)) {
  7. $host = "localhost";
  8. $dbUsername = "root";
  9. $dbPassword = "";
  10. $dbname = "loginsystem";
  11. //create connection
  12. $conn = new mysqli($host, $dbUsername, $dbPassword, $dbname);
  13. if (mysqli_connect_error()) {
  14. die('Connect Error('. mysqli_connect_errno().')'. mysqli_connect_error());
  15. } else {
  16. $SELECT = "SELECT user_email From users Where user_email = ? Limit 1";
  17. $INSERT = "INSERT Into users (user_name, user_password, phone_number, user_email,) values(?, ?, ?, ?)";
  18. //Prepare statement
  19. $stmt = $conn->prepare($SELECT);
  20. $stmt->bind_param("s", $user_email);
  21. $stmt->execute();
  22. $stmt->bind_result($user_email);
  23. $stmt->store_result();
  24. $rnum = $stmt->num_rows;
  25. if ($rnum==0) {
  26. $stmt->close();
  27. $stmt = $conn->prepare($INSERT);
  28. *$stmt->bind_param("ssis", $user_name, $user_password, $phone_number, $user_email);*
  29. $stmt->execute();
  30. echo "New record inserted sucessfully";
  31. } else {
  32. echo "Someone already registered using this email";
  33. }
  34. $stmt->close();
  35. $conn->close();
  36. }
  37. } else {
  38. echo "All field are required";
  39. die();
  40. }
  41. ?>
Add Comment
Please, Sign In to add comment