Guest User

Untitled

a guest
Mar 6th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. <div id="sign-up-bottom-border">
  2. <br>
  3. <form action="" id="sign-up-form">
  4. <label class="sign-up-label">Username<br>
  5. <input class="sign-up-textbox" name="username" type="text" placeholder="Username...">
  6. </label>
  7. <br>
  8. <br>
  9. <label class="sign-up-label">Password<br>
  10. <input class="sign-up-textbox" name="password" type="password" placeholder="Password...">
  11. </label>
  12. <br>
  13. <input id="sign-up-button" onclick="submitmyform();" type="submit" value="SIGN UP" name="signup">
  14. <br>
  15. </form>
  16. </div>
  17.  
  18. <?php
  19. //Connect to database
  20. $connection = new MongoClient();
  21.  
  22. //Select a database
  23. $db = $connection->ecommerce;
  24.  
  25. //Select a collection
  26. $collection = $db->customers;
  27.  
  28. //Extract the data that was sent to the server
  29. $username = filter_input(INPUT_POST, 'username', FILTER_SANITIZE_STRING);
  30. $password = filter_input(INPUT_POST, 'password', FILTER_SANITIZE_STRING);
  31.  
  32. //Convert to PHP array
  33. $customerData = [
  34. "username" => $username,
  35. "password" => $password
  36. ];
  37.  
  38. //Add the customer to the database
  39. $returnVal = $collection->insert($customerData);
  40.  
  41. //Close the connection
  42. $connection->close();
  43. ?>
  44.  
  45. function submitmyform(){
  46. data=$('#sign-up-form').serialize();
  47. $.ajax({
  48. url: "sign_up.php",
  49. type: 'POST',
  50. data: data,
  51. async: false,
  52. dataType: 'html',
  53. });
  54. }
Add Comment
Please, Sign In to add comment