php - redirect to other page when click submit button -


i'm try make login form.

i want show error messages on same page after user has clicked submit button.

if user logged system correct information should go index page.

this code have written, doesn't work - going same page every time.

<?php  if (isset($_post['login'])) { $uname = $_post['uname']; $pass = $_post['pass'];  $query = mysql_query("select *from user username='$uname'") or  die(mysql_error()); $numrows = mysql_num_rows($query);  if ($numrows != 0) { while ($row = mysql_fetch_assoc($query)) { $dbuname = $row['username']; $dbpassword = $row['password']; $status = $row['status']; } if ($status == 0) { ?>  <div class="alert alert-danger" style="text-align: center ; font-size: 17px;"  role="alert">your account not yet activated.please check email activate account.</div> <?php  } else if ($uname == $dbuname && $pass == $dbpassword) {  $_session['username'] = $uname; header('location: index.php');  ?>  <?php  } else { ?>  <div class="alert alert-danger" style="text-align: center ; font-size: 17px;"  role="alert">incorrect password.</div> <?php } } else {  ?>  <div class="alert alert-danger" style="text-align: center ; font-size: 17px;"  role="alert">incorrect username.</div> <?php } }    ?>  <form name="add" action="login-jobseeker.php" method="post" enctype="multipart/form-data" > <table class="table "> <tr> <td>username</td> <td> <input type="text"  required name="uname" class="form-control col-lg-12 "  placeholder="title"> </td>  </tr>  <tr> <td>password</td> <td> <input type="password"  required name="pass" class="form-control col-lg-12 "  placeholder="name"> </td> </tr> <tr> <td></td> <td> <a href="register.php?type=<?php echo $type ?>" >register free account</a> </td> </tr> <tr> <td></td> <td> <a href="forget.php" >forget password??</a> </td> </tr>  <tr> <td></td> <td> <input type="submit" name="login" class="btn btn-primary" value="login"> </td> </tr> </table> </form>   

how resolve issue?

i think you're redirecting page in form-action.

<form name="add" action="login-jobseeker.php" method="post" enctype="multipart/form-data" > 

put page want go in action.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -