Guest User

Untitled

a guest
Apr 15th, 2021
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. <input id="tyEMail" type="email" placeholder="e-mail">
  2. <input id="tyPassword" type="password" placeholder="parola">
  3. <button id="logInBtn">Log in</button>
  4.  
  5. <script>
  6. $("#logInBtn").click(() => {
  7. $.ajax({
  8. type: 'POST',
  9. url: 'http://localhost/e-sesizari/api/user/new.php',
  10. data: {
  11. fname: 'pola',
  12. lname: 'pizda',
  13. email: $("#tyEMail").val(),
  14. phone: '112'
  15. },
  16. dataType: 'json',
  17. contentType: 'application/json',
  18. success: function (data) {
  19. if (data.type == 'success')
  20. {
  21. let now = new Date();
  22. now.setTime(now.getTime() + (30 * 24 * 60 * 60 * 1000))
  23. document.cookie = 'session_key=' + data.session_key + '; expires' + now.toUTCString();
  24. console.log('Autentificat cu succes! Cheie: ', data.message);
  25. }
  26. else
  27. console.error(data.message);
  28. }
  29. })
  30. });
  31. </script>
Advertisement
Add Comment
Please, Sign In to add comment