title: PHP Trim user input in the text field to avoid user just entering spaces
body: <p>When user enters just spaces in the text field and submits the form it should trim it and if its empty return an error. I guess when just line of spaces are trimmed it is like empty string right?</p>
  
  <p>At the moment in my php ive got whenever user leaves the textfield blank it prints out an error but i cant get it trimmed if user enters few spaces. It just allows user to submit it.</p>
  
  <pre><code>function test_input($field)
  {
      $field = trim($field);
      return $field;
  }
  </code></pre>