Form validation doesn’t work after adding the database in the add.php page (A project from net ninja)

You have not set an exit point from the script and the script continues to run, even if errors are found. You can add die or etc. like this:

if (array_filter($errors)) {
    echo "There are errors in the form";
    die(1); //or exit or return if it is function
} else {
    // to make sure the data incerted inside the database is safe
    $email = mysqli_real_escape_string($conn, $_POST['email']);
    $title = mysqli_real_escape_string($conn, $_POST['title']);
    $ingredients = mysqli_real_escape_string($conn, $_POST['ingredients']);
}

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top