title: PHP Prevent the submission of empty fields containing only "space" characters
body: <p>When using PHP how can I validate a simple text input to check if the field only contains space character, I want to prevent it from being possible to sign up to my website with a blank name consisting of just spaces and the same goes for other inputs such as comments? If I check if it is empty it just returns it as not empty as it considers a space as a character regardless.</p>
  
  <p>For future reference the answer was to first trim my post data:</p>
  
  <pre><code>$variable = mysql_real_escape_string(stripslashes(trim($_POST['field'])));
  </code></pre>
  
  <p>Also sanitised it here and then as for validation, you can then just use empty():</p>
  
  <pre><code>if(empty($variable)) {
  //do something
  }
  </code></pre>