登录表单 - 输入类型更改

时间:2016-05-18 20:10:22

标签: php jquery mysql

我正在尝试将登录名从电子邮件和密码组合更改为ID号作为密码组合。每当我更改"电子邮件"在输入表格中" Employeeid"这是行不通的。我在关联的mysql数据库中创建了一个名为Employeeid的字段,所以我不确定问题出在哪里。

这是我当前的代码(输入要登录的电子邮件;我想将此更改为让人们键入其Employeeid):

<script language="javascript">

  $(function() {
    $("#password").click(function() {
      $("#password_retrieval").text("Click here to retrieve password");
    });

    $("#password_retrieval").click(function() {
      if (!$("#email").val()) {
         alert ("Please choose a login to get the password");
         return false;
      }

      var post_vars      = {};
      post_vars["email"] = $("#email").val();     
      post_vars["Employeeid"] = $("#Employeeid").val();             

      var host = "<?= $config["host"] ?>";
      $.post(host + "password_retrieval", post_vars, function( data ) {
          data = data.trim();
          if (data == "OK")
              $("#password_retrieval").text("Password reminder sent to " + $("#email").val());
      });

      return true;
    });

    $("#submit_button").click(function() {
            // get rid of any errors
            $(".error").css("display", "none");


            // let the visitor know something is happening
            $("#submit_button").text('Logging in');

            // build the post vars
            var post_vars = {};

            post_vars["email"]     = $("#email").val();
            post_vars["Employeeid"]     = $("#Employeeid").val();
            post_vars["password"]  = $("#password").val();

            // post the form
            var host = "<?=$config["host"]?>";

            $(".error").css("display", "none");

            // login
            // test/json_test.php

            $.post(host + "login", post_vars, function( data ) {
                   if (data.status == "BAD_PASSWORD") {
                       $("#password_error").css("display", "inline");
                       $("#password_retrieval").css("display", "inline");
                       $("#submit_button").text("Login");                                   
                   }
                   else if (data.status == "OK") {
                        $(".error").css("display", "none");
                        window.location.replace(data.redirecturl);                                
                   }

                   return false;
            })                        

            return false;
     });                
  });
</script>


  </head>
  <body class="container">
   <form class="form-horizontal">
  <fieldset>

 <!-- Form Name -->
<legend>Login</legend>

<div class="control-group">
  <label class="control-label" for="email">Email</label>
  <div class="controls">
    <input id="email" name="email" class="input-xlarge">
  </div>
</div>


<!-- Text input-->
<div class="control-group">
  <label class="control-label" for="password">Password</label>
  <div class="controls">
    <input id="password" name="password" type="password"     placeholder="password" class="input-xlarge">
    &nbsp;&nbsp;<span class="error" id="password_error">Incorrect     password</span>
    <span id="password_retrieval">Click here to retrieve password</span>
  </div>
</div>

<!-- Button -->
<div class="control-group">
  <label class="control-label" for="submit_button"></label>
  <div class="controls">
    <button id="submit_button" name="submit_button" class="btn btn-    primary">Login</button>
    <span class="updated" id="updated">Login</span>
  </div>
</div> 
</fieldset>
</form>
  </body>
</html>

0 个答案:

没有答案