lundi 5 septembre 2022

checkbox does not register PHP

I am trying to make a form. I want to display a message if you have checked the checkbox and when submit it. If the checkbox is not checked, I do not want the massage.

I have tried a lot of things and I have searched a lot but can not make it work.

If I use 'isset', it will never display the message. Not when the box is checked and not when it is not checked. When I use '!isset' is will always display the message.

Can someone help me? Thanks

Code:

<?php
if ($_SERVER['REQUEST_METHOD']==='POST' ){

        if (isset($_POST['invoeren'])){
            echo'Invoer is gelukt';
        }
    }?>
    
<form>
<p>
    <label for="invoeren">wil je dit invoeren?</label>
    <input type="checkbox" id="invoeren" naam="invoeren">
 </p>
 <p>
    <input type="submit" value="submit">
 </p>
 </form>



Aucun commentaire:

Enregistrer un commentaire