Home Sign In just refreshes the page php html
Reply: 1

Sign In just refreshes the page php html

humphrey
1#
humphrey Published in 2018-02-14 10:10:55Z

My signin page just refreshes itself . Its been working for sometime now when I tried to make some few changes the issue stated so I deleted the changes and also tried different computers and browsers but still doing the same thing . So I cant login I tried all possible ways no luck. Here is my code .

<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>
Niels
2#
Niels Reply to 2018-02-14 10:14:51Z

You're using jquery to handle your login functionality yet you don't prevent the default execution.

This part

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

Should contain

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

In order to stop the browser posting your form.

You can read more about it in the jQuery documentation

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.300615 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO