mysql - php not allowing login -


i have created log in system when log in email or password incorrect though it's test user , details correct. maybe doesn't match database, have checked on , on again. can't seem find problem. appreciated.

php:

if(isset($_session['user'])!="") { header("location: index-user.php"); }  if(isset($_post['btn-login'])) { $email = mysql_real_escape_string($_post['email']); $upass = mysql_real_escape_string($_post['pass']);  $email = trim($email); $upass = trim($upass);  $res=mysql_query("select user_id, user_name, user_pass users user_email='$email'"); $row=mysql_fetch_array($res);  $count = mysql_num_rows($res); // if uname/pass correct returns must 1 row  if($count == 1 && $row['user_pass']==md5($upass)) {     $_session['user_name'] = $row['user_id'];     header("location: index-user.php"); } else {     ?> <script>alert('email or password invalid.');</script>     <?php }  } ?> 

html:

<input class="loginmodal-input" type="text" name="email" placeholder="email" required> <input class="loginmodal-input" type="password" name="upass" placeholder="password" required> <button type="submit" name="btn-login" id="login-btn" class="login btn-block loginmodal-submit">login</button> <button class="login-btn-2 btn btn-lg btn-block" type="button" aria-label="close" value="cancel" data-dismiss="modal"> cancel</button> 

mysql info: user_id user_name user_email user_pass

the value of $upass empty, because there no form field name 'pass'.

change this:

$upass = mysql_real_escape_string($_post['pass']); 

into this:

$upass = mysql_real_escape_string($_post['upass']); 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -