title: unknown column 'email' in where clause
body: <p>I have problem with this code. It gives me 'Unknown column 'email' in where clause.
  I tried almost everything, but I don't know what is the problem. I am beginner so please be gentle :)</p>
  
  <p>Any ideas how to solve it?</p>
  
  <p>Thanks a lot </p>
  
  <pre><code>    session_start();
      include('connect.php');
      if(isset($_POST['submit']))
      //when isn't username in form
      if($_POST['firstname'] == '')
      {
          $_SESSION['error']['firstname'] = 'First name is required';
      }
      if($_POST['surname'] == '')
      {
          $_SESSION['error']['surname'] = 'Surname is required';
      }
      //when email isn't in form
      if($_POST['email'] == '')
      {
          $_SESSION['error']['email'] = 'Email is required';
      }
      //check if is email in correct format
      if(preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9._-]+)+$/", $_POST['email']))
      {
          //email is in correct format and exist?
          $email = $_POST['email'];
          $sql1 = "SELECT * FROM users WHERE email = '$email'";
          $result1 = mysqli_query($connect, $sql1) or  die(mysqli_error($connect));
          if(mysqli_num_rows($result1) &gt; 0)
          {
              $_SESSION['error']['email'] = 'Email is already used';
          }
      }
      else
      //error for wrong format of email
      {
          $_SESSION['error']['email'] = 'Your email is in wrong format';
      }
      //when isn't password in form
  if($_POST['password'] == '')
  {
      $_SESSION['error']['password'] = 'Password is required';
  }
  //when is error -&gt; registration form
  /*if(isset($_SESSION['error']))
  {
      header("Location: index.php");
      exit();
  }
  else
  */
  {
      $firstname = mysqli_real_escape_string($connect,$_POST['firstname']);
      $surname = mysqli_real_escape_string($connect,$_POST['surname']);
      $email = $_POST['email'];
      $password =  mysqli_real_escape_string($connect,$_POST['password']);
      $phone_number = mysqli_real_escape_string($connect,$_POST['phone_number']);
      $note = mysqli_real_escape_string($connect,$_POST['note']);
  
      $sql2 = "INSERT INTO users (firstname, surname, email, phone_number, note, password) VALUES ('$firstname', '$surname',
      '$email', '$phone_number', '$note','$password')";
      $result2 = mysqli_query($connect, $sql2) or die('Error: ' .mysqli_error($connect));
  </code></pre>