I want to check, if the User, I add to the database, is already existing and if something was typed in the formular. When the checks are correkt the data I typed in the formular should be added to my database, but it doesn`t. It has to do something with the while statement, because when I delete these lines it works but it adds an user everytime i refresh the page.
    <?php
                    $host = 'localhost';
                    $user = 'root';
                    $password = 'FIoLTAZo1pEar83N';
                    $dbname = 'studenten';
                    $dsn = 'mysql:host='. $host .';dbname='. $dbname;
                    $pdo = new PDO($dsn, $user, $password);
                    $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
                    $pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
                    if(isset($_POST["u_name"]) && (null !== $_POST["u_name"])){
                        if ($_SERVER["REQUEST_METHOD"] == "POST") {
                            $user_name = $_POST["u_name"];
                            $first_name = $_POST["vorname"];
                            $last_name = $_POST["nachname"];
                            $user_password = $_POST["passwort"];
                        }
                    }
                    if(isset($_POST["u_name"]) && (null !== $_POST["u_name"])){
                        $suchen = $_POST['u_name'];
                        $sql = 'SELECT * FROM studenten WHERE user_name LIKE ?';
                        $stmt = $pdo->prepare($sql);
                        $stmt->execute([$suchen]);
                        while($row = $stmt->fetch(PDO::FETCH_ASSOC)){
                            if($row['user_name'] == null){
                                $sql = 'INSERT INTO studenten(user_name, first_name, last_name, user_password) VALUES(:user_name, :first_name, :last_name, :user_password)';
                                $stmt = $pdo->prepare($sql);
                                $stmt->execute(['user_name' => $user_name, 'first_name' => $first_name, 'last_name' => $last_name, 'user_password' => $user_password]);
                                unset($_POST["u_name"]);
                        }}}                            
                ?>
    <form id='formular_eins' method="post" action="admin.php">
                        <p class="eigenschaften">User Name:</p>
                        <input type='text' name='u_name' placeholder='User Name' required maxlength="7" minlength="7">
                        <br><br>
                        <p class="eigenschaften">Vorname:</p>
                        <input type='text' name='vorname' placeholder='Vorname' required>
                        <br><br>
                        <p class="eigenschaften">Nachname:<p>
                        <input type='text' name='nachname' placeholder='Nachname' required>
                        <br><br>
                        <p class="eigenschaften">Passwort:</p>
                        <input type='text' name='passwort' placeholder='Passwort' maxlength="15" minlength="6" required>
                        <br><br><br>
                        <button type='submit' name="btn" class="btn_speichern" onclick="leeren()">Speichern</button>
                    </form>
 
    