php - Values not set in $_POST -
i have login form , script on index.php. problem php code doesn't seem pick fields set in.
here php code:
<?php if(isset($_post['user'])||isset($_post['pass'])){ ?> <script> $('#login-drop').addclass('open'); console.log('opening'); </script> <?php if(isset($_post['user'])){ if(isset($_post['pass'])){ login(); } else{ ?> <script> $('#pass-group').addclass('has-error'); console.log('password has error.'); </script> <?php } } else { ?> <script> $('#user-group').addclass('has-error'); console.log('user has error'); </script> <?php } } else { echo 'nothing entered'; } function login(){ echo 'both username , password entered.'; } ?> here html form:
<form class="form-horizontal" method="post" action="?login"> <fieldset> <legend>log in</legend> <div class="form-group" id="user-group"> <label for="user" class="col-lg-2 control-label">username</label> <div class="col-lg-10"> <input class="form-control" id="user" placeholder="username or email" type="text"> </div> </div> <div class="form-group" id="pass-group"> <label for="pass" class="col-lg-2 control-label">password</label> <div class="col-lg-10"> <input class="form-control" id="pass" placeholder="password" type="password"> <div class="checkbox"> <label> <input type="checkbox"> remember me </label> </div> </div> </div> <div class="form-group"> <div class="col-lg-10 col-lg-offset-2"> <button class="btn btn-primary" type="submit">log in</button> </div> </div> </fieldset> </form> even if come in fields still says nothing entered. can't see problem tend overlook things lot.
ps. i'm using bootstrap classes should work. i've tested them.
you need give input element names, otherwise values not submitted. ids may useful javascript code, don't solve problem.
so want is
<input name="user" id="user" ... > php html forms
No comments:
Post a Comment