php - Having some trouble with synchronizing prints between jquery and javascript -


i have 2 forms, 1 login form , 1 register form. have added jquery creating error message displays every input not filled, can't manage php create error message saying "invalid info" when fields filled info wrong. have tried ajax, can't work @ all.

my php code:

require 'dbconnect.php';  if(isset($_post['login-btn'])){      $email = strip_tags($_post['email']);     $password = strip_tags($_post['password']);      $email = $dbcon->real_escape_string($email);     $password = $dbcon->real_escape_string($password);      $query = "select email, password members email='$email'";     $result = $dbcon->query($query);      $row = $result->fetch_array();      $count = $result->num_rows;       if(password_verify($password, $row['password']) && $count==1) {         header("location: home.php");         die();     } else{         echo "invalid email or password!";     }      $dbcon->close(); } 

jquery:

$(document).ready(function(){ $('form').submit(function() {     var isformvalid = true;     $('input').each(function () {         if ($.trim($(this).val()).length == 0) {             $(this).addclass('highlight');             isformvalid = false;         }         else {             $(this).removeclass('highlight');         }     });      if (!isformvalid) {         $('.fillfields').remove();         $('input:image').before('<p class="fillfields">you need fill fields</p>');     }      return isformvalid;   });  }); 

html:

<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <script               src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <?php include 'login.php';?> <script src="test.js"></script> <link rel='stylesheet' type='text/css' href='fuck.css'/> <title>wessoc</title> </head> <body>    <header class="login-header"></header> <div class="container">    <div class="form">       <form id="login-form" method="post">         <input id="email" name="email" type="text" placeholder="epost"/>         <br/>         <input id="password" name="password" type="password" placeholder="passord"/>         <input id="login-btn" name="login-btn" type="image" src="images/logginn.png" value="submit"/>       </form>        <div id="register-link">         <a href="registrationpage.php"><img src="images/registrerbruker.png"/></a>        </div>     </div>  </div> </body> 


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -