title: error email already exists
body: <p>I got this code from someone here from stack overflow I copied it and I tried it out but I doesn't work the way I want it to if I put an already existing email address from my database it gives an error saying email address already taken please choose another email. but when I submit an email address that is not in the database it still displays the same error how can this be fixed  </p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;Untitled Document&lt;/title&gt;
  &lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  $(document).ready(function(){ //newly added 
  $('#submit').click(function() {alert("Email already exists. Please choose a different email");
  var emailVal = $('#email').val(); // assuming this is a input text field
  
  $.post('checkemail.php', {'email' : emailVal}, function(data) {
    if (data == 1)
    { 
       $("#registration").submit();
    }
   else
    {
  
        return false;
    }
  
   });
   });});
   &lt;/script&gt;
  
    &lt;/head&gt;
   &lt;body&gt;
  
   &lt;form id="registration" name="registration" method="post" action="profile1.php"&gt;
   &lt;p&gt;email
   &lt;input type="text" name="email" id="email" /&gt;
   &lt;/p&gt;
   &lt;p&gt;
   &lt;input type="button" name="submit" id="submit" value="submit" /&gt;
   &lt;/p&gt;
   &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and here is the php code</p>
  
  <pre><code>&lt;?php
  include("con.php");
  
  $sql = "SELECT email FROM registered_d WHERE email = " .$_POST['email'];
  $select = mysqli_query($con, $sql);
  $row = mysqli_fetch_assoc($select);
  
     if (mysqli_num_rows &gt; 0) {
    echo "0"; // email exists
   }else{
    echo "1"; // email doesn't exists
   return;}
  ?&gt;
  </code></pre>
  
  <p>can someone help me solve this </p>