! empty (trim ($ _ POST ['username'])

Ok problem polega na tym, że kiedy używam funkcji przycinania, to nie działa, ale kiedy uruchamiam kod bez funkcji przycinania, to działa, ale nie działa poprawnie (formularz akceptuje białe znaki)

<?php
session_start();
unset($_SESSION['username']);

 if (isset($_SESSION['username']))
    {echo "You are in already";}

 else if ($_SERVER['REQUEST_METHOD'] == 'POST')
 {      

 if (!empty(trim($_POST['username'])) && !empty(trim($_POST['email'])))
    {
        $uname = htmlentities($_POST['username']);
        $email = htmlentities($_POST['email']);
  $_SESSION['username'] = $uname;

            echo "THANKS: " . $uname . "<br />";
    }
 else { echo "fill the goddemn field"; }


  } else { ?>

<form action="index.php" method="post">
 <label for="username">USERNAME:</label>
 <input type="text" name="username" />
 <label for="E-MAIL">E-mail:</label>
 <input type="text" name="email" />
 <input type="submit" value="Enter" />
</form>


<?php    } ?>

Spróbowałem instrukcjihttp://php.net/manual/en/function.trim.php ale trudno było to przeczytać i niczego nie wymyśliłem.

questionAnswers(1)

yourAnswerToTheQuestion