title: PHP code to check for login credentials on mysql db?
body: <p>I have an HTML page that sends an Ajax HTTP request to the PHP file on the webserver to check if the username or password is valid ? All i am doing is a select on the database to check if it exist is this the right way or do i have a better way of checking for credentials ? </p>
  
  <pre><code>&lt;?php
  
  header("Access-Control-Allow-Origin: *");
  
  $usrnm = $_POST['usrnm'];
  $pswdlogin = $_POST['pswdlogin'];
  
  $con=mysqli_connect("localhost","root","root123","bank","3306");
  
  
  mysqli_select_db($con,"bank");
  
  $result = mysqli_query($con,"SELECT * FROM registration WHERE email = '".$usrnm."' AND password='".$pswdlogin."' ");
  
  $rows = mysqli_num_rows($result); 
  
  if ($rows == 1) {
    echo "Valid!";
  }
  
  else{
   echo "In Valid!";
  
  }
  
  mysqli_close($con);
  
  ?&gt;
  </code></pre>