只需刷新页面php html

时间:2018-02-14 10:10:56

标签: php html css mysql

我的登录页面只是刷新自己。它现在已经工作了一段时间,当我试图对问题进行一些修改时,所以我删除了更改,并尝试了不同的计算机和浏览器,但仍然做同样的事情。所以我无法登录我尝试了所有可能的方法没有运气。 这是我的代码。

<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>King Musa Transport System</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.5 -->
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="dist/css/AdminLTE.min.css">
    <!-- iCheck -->
    <link rel="stylesheet" href="plugins/iCheck/square/blue.css">

    <!-- jQuery 2.1.4 -->
    <script src="plugins/jQuery/jQuery-2.1.4.min.js"></script>
    <!-- Bootstrap 3.3.5 -->
     <!-- jQuery -->
    <script src="bootstrap/jquery/jquery.min.js"></script>

    <script src="bootstrap/js/bootstrap.min.js"></script>
    <!-- iCheck -->

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body class="hold-transition login-page">
    <div class="login-box">
      <div class="login-logo">
        <a href="index.php"><b>Powered by King Musa Systems.
      </div><!-- /.login-logo -->
      <div class="login-box-body">
        <p class="login-box-msg">Sign in to start your session</p>
        <form class="form-horizontal"   id="myform" method="post">
          <div class="form-group has-feedback">
            <input type="text" class="form-control" id ="username" name="username">
            <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
          </div>
          <div class="form-group has-feedback">
            <input type="password" id ="password" name = "password" class="form-control">
          </div>
          <div class="row">
            <div class="col-xs-8">
              <div class="checkbox icheck">
                <label>
                </label>
              </div>
            </div><!-- /.col -->
            <div class="col-xs-4">
              <button type="submit" name ="submit" id ="submit_login" class="btn btn-primary btn-block btn-flat">Sign In</button>
            </div><!-- /.col -->
          </div>
        </form>

        <div class="social-auth-links text-center">
        </div><!-- /.social-auth-links -->
         <span id="showerrors"></span>
<div class ="showerrors"></div>
        <a href="#">I forgot my password</a><br>
        <a href="register.html" class="text-center">Register a new membership</a>

      </div><!-- /.login-box-body -->
    </div><!-- /.login-box -->


    <script>
    $(document).ready(function(){
    $("#showerrors").css('display', 'none', 'important');
     $("#submit_login").click(function(){   
          username=$("#username").val();
          password=$("#password").val();
          if(username==""){
                    $(".showerrors").html("<p style='color:red'>please type  username</p>");

                     }
         else if(password==""){
                     $(".showerrors").html("<p style='color:red'>please type  password</p>");

                     }
          $.ajax({
           type: "POST",
           url: "dologin.php",
            data: "username="+username+"&password="+password,
           success: function(datasender){    
            //debugger;
            if(datasender)    {
            //$(".showerrors").html(datasender.message);
//alert(datasender.message);
             window.location="index.php";
            }
            else {

            }
           },
           beforeSend:function()
           { 
            $("#showerrors").css('display', 'inline', 'important');
            $("#showerrors").html("<p style='color:green'>Loading...")
           }
          });
        return false;
    });
});

//Read more: http://www.ondeweb.in/ajax-login-form-with-jquery-and-php/#ixzz3d9UpBgG7

        </script>


  </body>
</html>

1 个答案:

答案 0 :(得分:2)

您正在使用jquery来处理登录功能,但不会阻止默认执行​​。

这部分

$("#submit_login").click(function(){   
      username=$("#username").val();
      password=$("#password").val();

应包含

$("#submit_login").click(function(event){
      event.preventDefault();
      username=$("#username").val();
      password=$("#password").val();

为了阻止浏览器发布您的表单。

您可以在jQuery documentation

中详细了解相关信息