I have a problem with trim, it doesnt work as i expected, when the user writes only spaces in username form ("studentname") it should write you didint fill all fields ("niste izpolnili vsa polja") and i dont know how to achieve that, sorry if question is duplicate but i didnt find the answer to fix my problem
here is the code:

```html
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>vaja 5: PHP</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
 <link rel="stylesheet" type="text/css" href="style.css">
    </head>
<body>

<div class="container">
  <form name='form' method='post'>
  <label class="registracija">Registracija</label>

    <div class="form-group row">
      <label for="username" class="col-sm-2">Vnesi ime</label>
    <div>
        <input type="text" id="studentname" name="studentname">
       </div>
    </div>

<div class="form-group row">
      <label for="password" class="col-sm-2">Vnesi geslo</label>
      <div>
        <input type="password" id="password1" name="password1">
      </div>
    </div>

 <div class="form-group row">
      <label for="password" class="col-sm-2">Geslo še enkrat</label>
      <div>
        <input type="password" id="password2" name="password2">
      </div>
    </div> 

   <div>
        <input type="submit" value="Pritisni me" name="button">
      </div>
      </form>
</div>

<p>
<div class="container">
 <?php
if (isset($_POST["button"]))
{
echo $_POST['studentname']; 
} 
?>
<br>
<?php
if (isset($_POST["button"])) {
 $studentname = trim( $_POST['studentname'] );
 $password1 = $_POST ['password1'];
 $password2 = $_POST ['password2']; }

if ($_POST['studentname'] == "" || $_POST['password1'] == "" || $_POST['password2'] == "") {
        echo "Niste izpolnili vsa polja";
 } else 
if ($_POST['password1']!= $_POST['password2']) {
  echo "Gesli se ne ujemata";
 } else {
        echo "Registracija uspela";
    }

?>

<div>
</p>

 <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
 <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
 <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>
```