Guest User

Untitled

a guest
Nov 21st, 2018
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. $mysqli = new mysqli('ip', 'user', 'pass', 'dbname');
  2.  
  3. $post = filter_input_array(INPUT_POST);
  4. if (isset($post)) {
  5.  
  6.  
  7.  
  8. $skills = $mysqli->real_escape_string($post['skills']);
  9.  
  10. if (isset($post['email'])) {
  11. $temp_email= $post['email'];
  12.  
  13. $sql = $mysqli->query("SELECT email FROM users WHERE email='$temp_email'");
  14. if ($sql->num_rows > 0) {
  15. $msg = "email already exists!";
  16. } else {
  17. $email = $temp_email;
  18. }
  19. } else {
  20. $msg = "Please enter your email!";
  21. }
  22.  
  23. if (isset($post['username'])) {
  24. $temp_username= $post['username'];
  25.  
  26. $sql = $mysqli->query("SELECT username FROM users WHERE username='$temp_username'");
  27. if ($sql->num_rows > 0) {
  28. $msg = "Username already exists!";
  29. } else {
  30. $username = $temp_username;
  31. }
  32. } else {
  33. $msg = "Please enter your username!";
  34. }
  35.  
  36.  
  37. if (isset($post['password'])) {
  38. if ($post['password'] === $post['confirmpassword']) {
  39.  
  40. $password = password_hash($password, PASSWORD_BCRYPT); //hash and bcrypt adds a level of security for the password so once it's saved into the database it will be saved as something else
  41. } else {
  42. $msg = "Two passwords do not match!";
  43. }
  44. } else {
  45. $msg = "Please enter your password!";
  46. }
  47.  
  48.  
  49. if(isset($post['captcha'])) {
  50. if ($post['captcha'] === $_SESSION['captcha']) {
  51. } else {
  52. $msg = "The captcha is not correct";
  53. }
  54. } else {
  55. $msg = "Please enter the captcha";
  56. }
  57.  
  58. if(isset($email) && isset($username) && isset($password)) {
  59. //if the query is successful, redirect to emailvalidation.php page
  60. $mysqli->query("INSERT INTO users (username,email,password,skills,active,activationCode)
  61. VALUES ('$username', '$email', '$password','$skills', '0', '$activationCodeString');
  62. ");
  63. // $mysqli->query($sql);
  64. }
Add Comment
Please, Sign In to add comment