Skip to content

Instantly share code, notes, and snippets.

@jblac
Last active December 10, 2015 10:29
Show Gist options
  • Save jblac/4421492 to your computer and use it in GitHub Desktop.
Save jblac/4421492 to your computer and use it in GitHub Desktop.
$('form').on('submit', function(e) {
e.preventDefault();
$.ajax({
type: "POST",
url: $(this).attr('action'),
data: $(this).serialize(),
success: function(resp) {
var obj = $.parseJSON(resp);
if (obj.resp == 0) {
$(this).alertBox(obj.err, { type: 'error'});
} else {
}
}
});
return false;
});
<?php
class user extends BM_Controller {
public function __construct() {
parent::__construct();
}
function login() {
if (isset($_POST['username'])) {
$this->load->model('bm_users');
$user = $this->bm_users->login($_POST);
if ($user !== 'failed') {
$data['1'];
} else {
$data['resp'] = '0';
$data['err'] = 'The username/password combination did not match. Please try again.';
}
$dta = json_encode($data);
echo $dta;
}
$this->load->view('login');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment