Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1.  
  2. `<?php
  3. $response = array();
  4. include 'db/conexionDB.php';
  5. include 'functions.php';
  6.  
  7.  
  8. $inputJSON = file_get_contents('php://input');
  9. $input = json_decode($inputJSON, TRUE);
  10.  
  11.  
  12. if(isset($input['email']) && isset($input['passw']) && isset($input['nombre'])){
  13. $username = $input['email'];
  14. $password = $input['passw'];
  15. $name= $input['name'];
  16.  
  17.  
  18. if(!emailExists($email)){
  19.  
  20.  
  21. $salt = getSalt();
  22.  
  23.  
  24. $passwordHash = passw(concatPasswordWithSalt($password,$salt),PASSWORD_DEFAULT);
  25.  
  26. //Query to register new user
  27. $insertQuery = "INSERT INTO users(email, name, passw, salt) VALUES (?,?,?,?)";
  28. if($stmt = $con->prepare($insertQuery)){
  29. $stmt->bind_param("ssss",$email,$name,$passwordHash,$salt);
  30. $stmt->execute();
  31. $response["status"] = 0;
  32. $response["message"] = "User created";
  33. $stmt->close();
  34. }
  35. }
  36. else{
  37. $response["status"] = 1;
  38. $response["message"] = "Email already in use";
  39. }
  40. }
  41. else{
  42. $response["status"] = 2;
  43. $response["message"] = "Missing mandatory parameters";
  44. }
  45. echo json_encode($response);
  46. ?>`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement