Test valeur check box en php

Bonjour,

Je voudrais tester la valeur d'un checkbox en php pour formulaire.

J'ai un champs check box défini comme ceci en html :

<input type="checkbox" name="syst.info.windows" id="syst.info.windows" />

Et je teste la valeur comme ca

if (isset($_POST['syst.info.windows']))
{
$Systinfowindows = 1;
}else{
$Systinfowindows = 0;
}

Seulement même checkée $Systinfowindows = 0 ...

Une idée ?
Configuration: Windows XP
Firefox 3.0.3

2 réponses

  1. salut

    Le pb vient du nom ke tu as donné à ton input.
    Une variable ne peut etre nommé ainsi c-à-dir avec des points.
    Utilise des "_" à la place.
    Essaie ça :

    <input type="checkbox" name="syst_info_windows" id="syst_info_windows" />

    Et je teste la valeur comme ca

    if (isset($_POST['syst_info_windows']))
    {
    $Systinfowindows = 1;
    }else{
    $Systinfowindows = 0;
    }

    Et tu verras ke ça marche.
    1. up
      1. Bonsoir,
        il faut lui mettre une value et la tester ensuite
        <input type="checkbox" name="syst.info.windows" id="syst.info.windows"  value="1" />


        et la recup:

        if(isset($_POST['syst.info.windows'])){
           if($_POST['syst.info.windows'] ==1){
        
        
        }
        
        
        }