title: PHP / MySQL: How to return info if record already exists (without update)
body: <p>I am using the below to insert a new row into a MySQL db. 
  The query for this is stored in a PHP file (<code>ajax.php</code>) and the input values are passed to this via an Ajax call in jQuery. </p>
  
  <p>Everything works as intended but I would like to return a message to the user if an email is already in the db. 
  I know how to update a db row using <strong>ON DUPLICATE KEY</strong> but <strong>can someone tell me how I can just check for this and echo something if it exists there already</strong> (i.e. without updating it) ?<br>
  (email is a single primary key so I only need to check for this column.)</p>
  
  <p><strong>My PHP:</strong> </p>
  
  <pre><code>$conn = new mysqli($servername, $username, $password, $dbname);
  $conn-&gt;set_charset("utf8");
  if($conn-&gt;connect_error){
      die("Connection failed: " . $conn-&gt;connect_error);
  }
  $email = $_POST["email"];
  $dob = $_POST["dob"]; 
  $sql = "INSERT INTO Users (email, dob) VALUES ('" . $email . "', '" . $dob . "')"; 
  if ($conn-&gt;query($sql)){ 
      echo 'DB Update successful'; 
  }else{ 
      echo 'DB Update failed'; 
  } 
  $conn-&gt;close();
  </code></pre>