Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <input id="tyEMail" type="email" placeholder="e-mail">
- <input id="tyPassword" type="password" placeholder="parola">
- <button id="logInBtn">Log in</button>
- <script>
- $("#logInBtn").click(() => {
- $.ajax({
- type: 'POST',
- url: 'http://localhost/e-sesizari/api/user/new.php',
- data: {
- fname: 'pola',
- lname: 'pizda',
- email: $("#tyEMail").val(),
- phone: '112'
- },
- dataType: 'json',
- contentType: 'application/json',
- success: function (data) {
- if (data.type == 'success')
- {
- let now = new Date();
- now.setTime(now.getTime() + (30 * 24 * 60 * 60 * 1000))
- document.cookie = 'session_key=' + data.session_key + '; expires' + now.toUTCString();
- console.log('Autentificat cu succes! Cheie: ', data.message);
- }
- else
- console.error(data.message);
- }
- })
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment