samedi 3 juin 2017

PHP: Why does else-block not work?

I have the following code:

<form action="" method="POST">
                                <input id="delete" name="delete" placeholder="Name" type="text"></b>
                                <input type="submit" name="deleteButton" value="Go!">   
                                </form>
                                <?php
                                if (isset($_POST['deleteButton'])) {
                                    $temp = $_POST['delete'];
                                    $deleteSQL = "DELETE FROM `berater` WHERE `Nachname` LIKE '$temp' OR `Vorname` LIKE '$temp' OR CONCAT(Vorname,' ', Nachname) LIKE '%$temp%'";
                                    $searchSQL = "SELECT FROM `berater` WHERE `Nachname` LIKE '$temp' OR `Vorname` LIKE '$temp' OR CONCAT(Vorname,' ', Nachname) LIKE '%$temp%'";
                                    $search = mysqli_query($db_link, $searchSQL);
                                    $loeschen = mysqli_query($db_link, $deleteSQL);

                                    if (!$search) {
                                        echo "Kein Datensatz gefunden!";
                                    } else {
                                        echo "$temp erfolgreich gelöscht.";
                                    }
                                }

I am new to php and thought the mysqli_query returns false if the name is not found in the database. What am I doing wrong here?

Aucun commentaire:

Enregistrer un commentaire