title: How do I tell the user their email is already registered?
body: <p>I have put a UNIQUE index on my email column in the database, and when I enter an already registered email the database does not update. so that works well. I now need to tell the user entering an already existing email(on the signup page) that it is already registered and redirect them to the homepage.</p>
  <p>Please check my SQL injection code too and correct if there are any errors.</p>
  <pre><code>&lt;?php
  
  $fullname = $_POST['fullname'];
  $email = $_POST['email'];
  $mobilenumber = $_POST['mobilenumber'];
  
  //prevent sql injection
  $fullname = stripslashes($fullname);
  $email = stripcslashes($email);
  $mobilenumber = stripslashes($mobilenumber);
  $fullname = mysql_real_escape_string($fullname);
  $email = mysql_real_escape_string($email);
  $mobilenumber = mysql_real_escape_string($mobilenumber);
  
  
  //Database Connection
  
  $conn = new mysqli(&quot;#&quot;,&quot;#&quot;,&quot;#&quot;,&quot;#&quot;);
  if($conn-&gt;connect_error){
      die('connection Failed : '.$conn-&gt;connect_error);
  }else{
          $stmt = $conn-&gt;prepare(&quot;insert into signup(fullname,email,mobilenumber)values(?,?,?)&quot;);
          $stmt-&gt;bind_param(&quot;ssi&quot;,$fullname,$email,$mobilenumber);
          $stmt-&gt;execute();
          header(&quot;Location:thankyou.html&quot;);
          $stmt-&gt;close();
          $conn-&gt;close();
  
  }
  
  ?&gt;
  </code></pre>