title: PHP bug while validating user name
body: <p>I'm building a website using PHP and I need to validate whether the name entered by the user is correct or not. Since JavaScript is client-side, I cannot completely rely on that, so here's my server-side function to validate the name of the user:</p>
  
  <pre><code>function validate_name($name) {
      $name = trim($name);  // only for the purpose of debugging &lt;---- edited comment
      echo $name;
      if (strlen($name) &lt;= 1) {
          return "small";
      } else if (has_numbers($name)) { 
          return "numbers";
      } else {
          return true;
      }
  }
  </code></pre>
  
  <p>After this, I check the input and display result accordingly:</p>
  
  <pre><code>function final_check() {
      if (validate_name($_POST["first_name"]) == "small") {
          echo "&lt;span class='error'&gt;Your first name cannot be empty&lt;/span&gt;";
          return false;
      } else if (validate_name($_POST["first_name"]) == "numbers") {
          echo "&lt;span class='error'&gt;Numbers are not allowed in your first name&lt;/span&gt;";
          return false;
      }
      return true;
  }
  </code></pre>
  
  <p>When I enter nothing in the <code>first_name</code> field, I get the empty error message; when I enter numbers, I get the numbers error message. However, when I do enter a valid name, it gives me the name empty error message.</p>
  
  <p>Here's the post data:</p>
  
  <pre><code>Array
  (
      [email] =&gt; ewf@gmail.com
      [first_name] =&gt; qwe
      [last_name] =&gt; wqe
      [password] =&gt; qwe
      [re_password] =&gt; qwe
      [gender] =&gt; Male
  )
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>Your first name cannot be empty
  </code></pre>
  
  <p>Any idea what I am doing wrong? I have been stumped for the past hour trying to fix this and I haven't been able to find a solution.</p>