Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['btnLogin'])){
- $username = $_POST['txtUsername'];
- $password = $_POST['txtPassword'];
- $u = new User(-1, 0, time(), $username, $password, '', '', '', 0, 0);
- if($u->Login() == true)
- {
- echo 'ok'; //Response to Ajax
- $_SESSION["IsLogin"] = 1; // Login Success
- $_SESSION["CurrentUser"] = (array)$u;
- }
- else
- {
- echo '<div class="alert alert-danger">Wrong Username or Password</div>';
- }
- }
- ?>
- jQuery(function($) {
- /* validation */
- $("#login-form").validate({
- rules:
- {
- txtUsername: {
- required: true,
- },
- txtPassword: {
- required: true,
- },
- },
- submitHandler: submitForm
- });
- /* validation */
- /* login submit */
- function submitForm()
- {
- var data = $("#login-form").serialize();
- $.ajax({
- type : 'POST',
- url : 'http://gtazombie.net/dangnhap.php',
- data : data,
- beforeSend: function()
- {
- $("#error").fadeOut();
- $("#error").html('<div class="alert alert-info"><center><i class="fa fa-refresh fa-spin fa-3x"></i></br><p>Loging</p></center></div>');
- },
- success : function(response)
- {
- if(response == 'ok'){
- $("#error").html('<div class="alert alert-success"><i class="fa fa-refresh fa-spin fa-3x fa-fw margin-bottom"></i>SUCCESS</div>');
- setTimeout(' window.location.href = "thongtin.php"; ',3000);
- }
- else{
- $("#error").fadeIn(1000, function(){
- $("#error").html('<div class="alert alert-danger">Wrong Username or Password</div>');
- });
- }
- }
- });
- return false;
- }
- /* login submit */
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement