PHP login form not working with mysql -


<?php if(array_key_exists("login",$_post)) {      $link = mysqli_connect("dbaddress", "dbname", "dbpassword", "dbuser");      if(!$_post['regno'])     {         $error .= "please enter registration number";     }     if(!$_post['password'])     {         $error .= "password required!";     }     if($error!="")     {         echo "<p>there errors in forms!</p>".$error;     }     else     {                            $query = "select * `users` registrationno = '".mysqli_real_escape_string($link, $_post['regno'])."'";                  $result = mysqli_query($link, $query);                  $row = mysqli_fetch_array($result);                  if (isset($row)) {                      $hashedpassword = md5(md5($row['id']).$_post['password']);                      if ($hashedpassword == $row['password']) {                          $_session['id'] = $row['id'];                         header("location: after_login.php");                         }                      else {            $error = "that email/password combination not found.";                           }                                              }                      else {             $error = "that email/password combination not found.";                  }                    }} ?>      <form method="post"> <center><input type="text" placeholder="enter username" name="regno"      id="log_username" class="sidelog"/> <input type="password"   placeholder="enter password" name="password"    id="real_pass" class="sidelog"/> </br><button id="button_log" type="submit" name="login" > go </button>    </center> </form> 

the page reloads whenever fill form , submit it. header isn't working. can't seem figure out why.if leave form empty, error string showing properly. used md5 encryption password. concatenated md5 of id in database password , md5 encrypted resulting string.

try may you,

     if ($hashedpassword == $row['password']) {            $_session['id'] = $row['id'];            header("location: after_login.php");            die();      }  

Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -