title: uploading a file(profile image) but the requirements for the file is being ignored
body: <p>im creating a <code>profile</code> which includes <code>uploading</code> a <code>profile pic</code>, name, phone, email and username.in the create profile page, the profile pic has requirements for size(less than 500kb) and file type(jpg,jpeg and png). if the size or file type doesnt meet the requirement then the user is kept on the create profile page and the problem is echoed. if the file type is right, the user is sent to the profile page where the info is displayed. The problem is when the file is type or size is wrong instead of keeping the user on the create profile page, the user is sent to the profile page but without a profile pic. It is like the else statement is ignored</p>
  <p>html</p>
  <pre><code>&lt;form class=&quot;&quot; action=&quot;editprofile.php&quot; method=&quot;post&quot;  enctype=&quot;multipart/form-data&quot;&gt;
    &lt;div class=&quot;form-group&quot;&gt;
      &lt;input type=&quot;text&quot; name=&quot;name&quot; class=&quot;form-control&quot; id=&quot;&quot; placeholder=&quot;Enter Name&quot; required&gt;
    &lt;/div&gt;
    &lt;div class=&quot;form-group&quot;&gt;
      &lt;input type=&quot;tel&quot; name=&quot;phone&quot;  class=&quot;form-control&quot; id=&quot;&quot; placeholder=&quot;Enter Phone&quot; required&gt;
    &lt;/div&gt;
  
  &lt;?php 
  if (isset($_POST['file'])) {
      if ($_POST['file'] == &quot;toolarge&quot;) {
          echo &quot;&lt;p class=\&quot;text-danger\&quot;&gt;file is too large&lt;/p&gt;&quot;;
      }
  }
  if (isset($_POST['error'])) {
      if ($_POST['error'] == &quot;unsuccessful&quot;) {
          echo &quot;&lt;p class=\&quot;text-danger\&quot;&gt;There was an error during the file upload&lt;/p&gt;&quot;;
      }
  }
  if (isset($_POST['file'])) {
      if ($_POST['file'] == &quot;wrongtype&quot;) {
          echo &quot;&lt;p class=\&quot;text-danger\&quot;&gt;file type is not supported&lt;/p&gt;&quot;;
      }
  }
  ?&gt;
    &lt;div class=&quot;form-group&quot;&gt;
      &lt;input type=&quot;file&quot; name=&quot;file&quot; value=&quot;&quot; required&gt;
    &lt;/div&gt;
  
   &lt;button type=&quot;submit&quot; class=&quot;btn btn-dark&quot;  name=&quot;submit-info&quot;&gt;Submit&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  <p>php</p>
  <pre><code>&lt;?php
  if (isset($_POST['submit-info'])) {
      //selecting file(in this case only picture extensions are allowed)//
      $fileName = $_FILES['file']['name'];
      $fileTmpName = $_FILES['file']['tmp_name'];
      $fileSize = $_FILES['file']['size'];
      $fileError = $_FILES['file']['error'];
      $fileType = $_FILES['file']['type'];
  
      $fileExt = explode('.', $fileName);
      $fileActualExt = strtolower(end($fileExt));
  
      $allowed = array('jpg', 'jpeg','png');
      if (in_array($fileActualExt, $allowed)) {
          if ($fileError === 0) {
              //500kb//
              if ($fileSize &lt; 500000) {
                  $fileNameNew = uniqid('',true).&quot;.&quot;.$fileActualExt;
                  $_SESSION['new_filename'] = $fileNameNew;
                  $fileDestination = 'uploads/'.$fileNameNew;
                  move_uploaded_file($fileTmpName, $fileDestination);
              }else {
                  header(&quot;Location:editprofile.php?file=toolarge&quot;);
              }
          }else {
              header(&quot;Location:editprofile.php?error=unsuccessful&quot;);
          }
      }else {
          header(&quot;Location:editprofile.php?file=wrongtype&quot;);
      }
  
      //upload data to database//
      $name1 = $_POST['name'];
      $name = ucwords($name1);
      $email = $_SESSION['email'];
      $username = $_SESSION['username'];
      $phone = $_POST['phone'];
      $fileNameNew1 = $_SESSION['new_filename'];
      $query = $conn-&gt;prepare(&quot;UPDATE info 
                      SET name=?, 
                          email=?, 
                          file=?, 
                          phone=?, 
                          username=? 
                  WHERE email ='&quot;.$_SESSION['email'].&quot;' 
                  OR username ='&quot;.$_SESSION['username'].&quot;' &quot;);
       $query-&gt;bind_param(&quot;sssss&quot;,$name, $email, $fileNameNew1,
                                  $phone, $username,);
      $query-&gt;execute();
      header(&quot;Location: profile.php?info=saved&quot;);
  }
  ?&gt;
  </code></pre>