mardi 28 juin 2016

PHP if statemant

I have the following if-statemant:

<br><br>
"if (isset($_POST['submit']) && !empty($_POST['submit']) && !empty($_POST['name']) && !empty($_POST['price'])) {
        include 'add.php';
        $message = "Product has been added";
        echo "<script type='text/javascript'>alert('$message');</script>";
    } else {
        $message = "Please fill all the fields";
        echo "<script type='text/javascript'>alert('$message');</script>";
    }" 
<br><br>

I want that the else part only executed if the submit button is pressed and any of the fields is empty, not before the button pressing.

Aucun commentaire:

Enregistrer un commentaire