Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- JS:
- $('.btn_measurements_login').click(function() {
- var email = $('.login_email').val();
- var password = $('.login_password').val();
- // Try to log the user in...
- $.ajax({
- type: "POST",
- url: "/Users/ajaxLogin",
- data: {email: email, password: password},
- success: function(html){
- if(html == 'true') {
- alert('logged in...');
- } else {
- alert('fail...');
- }
- },
- beforeSend:function() {
- $('.login_error').html("<img src='/img/loading.gif' class='loading'>").show();
- }
- });
- });
- PHP:
- public function ajaxLogin() {
- $this->layout = 'ajax';
- $tmp['User']['email'] = $this->request->data['email'];
- $tmp['User']['password'] = $this->request->data['password'];
- $this->log(print_r($tmp, TRUE), 'l');
- if ($this->Auth->login($tmp)) {
- $this->log("UID: " . $this->Auth->user('id'), 'l');
- $this->log("Logged in...", 'l');
- echo 'true';
- } else {
- $this->log("Failed...", 'l');
- echo 'false';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement