When trying to fetch data from a Mysql database using PHP, the following code gets a message:
Getting error:
undefined variable result.
<?php 
require_once 'login.php';
$conn = new mysqli($hn, $un, $pw, $db);
if ($conn->connect_error) die($conn->connect_error);
echo <<<_END
 <form action="fetchdata.php" method="post"><pre>
   Enter Country <input type="text" name="field">  
                <input type="submit" value="Display Records">
 </pre></form>
_END;
if (isset($_POST['field'])) {
  $field=$_post($conn,'field');
  $query="SELECT * FROM customers WHERE Country = '$field'";
  $result=$conn->query($query);
  if (!$result) die($conn->error);
  }
$rows = $result->num_rows;
 
     
     
     
     
    