title: Block registration if email already exists in mysqli database
body: <p>Users can use the same email address for different registration.</p>
  
  <p>Tried using different solutions from developers on Stack Overflow who have experienced the same problems that I have, including making the emailUsers column a UNIQUE KEY in the database table, and implementing some sort of jQuery, but not successful. Think the problem is I am missing an 'else if' block for duplicate email, but all the various ways I tried to implement this, it does not do anything.</p>
  
  <pre><code>&lt;div id="signup"&gt;
      &lt;div class="container"&gt;
          &lt;div class="row"&gt;
              &lt;div class="col-sm-6 offset-sm-1"&gt;
  
                  &lt;div class="signup-left position-fixed text-center"&gt;
  
                      &lt;img src="img/200.png"&gt;
                      &lt;br&gt;&lt;br&gt;&lt;br&gt;
                      &lt;?php
  
                      if(isset($_GET['error']))
                      {
                          if($_GET['error'] == 'emptyfields')
                          {
                              echo '&lt;div class="alert alert-danger" role="alert"&gt;
                                      &lt;strong&gt;Error: &lt;/strong&gt; Fill In All The Fields
                                      &lt;/div&gt;';
                          }
                          else if ($_GET['error'] == 'invalidmailuid')
                          {
                              echo '&lt;div class="alert alert-danger" role="alert"&gt;
                                      &lt;strong&gt;Error: &lt;/strong&gt; Please enter a valid email and user name
                                      &lt;/div&gt;';
                          }
                          else if ($_GET['error'] == 'invalidmail')
                          {
                              echo '&lt;div class="alert alert-danger" role="alert"&gt;
                                      &lt;strong&gt;Error: &lt;/strong&gt; Please enter a valid email
                                      &lt;/div&gt;';
                          }
                          else if ($_GET['error'] == 'invaliduid')
                          {
                              echo '&lt;div class="alert alert-danger" role="alert"&gt;
                                      &lt;strong&gt;Error: &lt;/strong&gt; Please enter a valid user name
                                      &lt;/div&gt;';
                          }
                          else if ($_GET['error'] == 'passwordcheck')
                          {
                              echo '&lt;div class="alert alert-danger" role="alert"&gt;
                                      &lt;strong&gt;Error: &lt;/strong&gt; Passwords donot match
                                      &lt;/div&gt;';
                          }
                          else if ($_GET['error'] == 'usertaken')
                          {
                              echo '&lt;div class="alert alert-danger" role="alert"&gt;
                                      &lt;strong&gt;Error: &lt;/strong&gt; This User name is already taken
                                      &lt;/div&gt;';
                          }
                          else if ($_GET['error'] == 'invalidimagetype')
                          {
                              echo '&lt;div class="alert alert-danger" role="alert"&gt;
                                      &lt;strong&gt;Error: &lt;/strong&gt; Invalid image type 
                                      &lt;/div&gt;';
                          }
                          else if ($_GET['error'] == 'imguploaderror')
                          {
                              echo '&lt;div class="alert alert-danger" role="alert"&gt;
                                      &lt;strong&gt;Error: &lt;/strong&gt; Image upload error, please try again
                                      &lt;/div&gt;';
                          }
                          else if ($_GET['error'] == 'imgsizeexceeded')
                          {
                              echo '&lt;div class="alert alert-danger" role="alert"&gt;
                                      &lt;strong&gt;Error: &lt;/strong&gt; Image too large
                                      &lt;/div&gt;';
                          }
                          else if ($_GET['error'] == 'sqlerror')
                          {
                              echo '&lt;div class="alert alert-danger" role="alert"&gt;
                                      &lt;strong&gt;Website Error: &lt;/strong&gt; Contact admin to have the issue fixed
                                      &lt;/div&gt;';
                          }
                      }
                      else if (isset($_GET['signup']) == 'success')
                      {
                          echo '&lt;div class="alert alert-success" role="alert"&gt;
                                  &lt;strong&gt;Signup Successful&lt;/strong&gt; Please Login from the login menu
                                  &lt;/div&gt;';
                      }
                  ?&gt;
          &lt;form id="signup-form" action="includes/signup.inc.php" method='post' enctype="multipart/form-data"&gt;
  
              &lt;input type="submit" class="btn btn-light btn-lg" name="signup-submit" value="Signup"&gt;
  
              &lt;br&gt;&lt;br&gt;
  
              &lt;a href="login.php"&gt;
                  &lt;i class="fa fa-sign-in fa-2x social-icon" aria-hidden="true"&gt;&lt;/i&gt;
              &lt;/a&gt;
              &lt;a href="contact.php"&gt;
                  &lt;i class="fa fa-envelope fa-2x social-icon" aria-hidden="true"&gt;&lt;/i&gt;
              &lt;/a&gt;
  
      &lt;/div&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>I want to be able to block a user from registering with the same email, and to generate an error message when the user tries to do this.</p>
  
  <p>EXTRA INFO: Can post further, detailed methods of me trying to make the emailUsers column a UNIQUE KEY, but when I do this, new users can no longer register, even if they use a different email.</p>