0

I have this php code on a page. I would like to highlight the entire input zone in red if the document as already been submitted but a button was not clicked :

<?php
function afficher_form_sexe() {
    if (isset($_POST['sexe'])) {
        echo ' value="f"';
        if ($_POST['sexe'] == 'f') {
            echo '<input type="radio" id="sexef" name="sexe" checked="checked"/><label for="sexef"> une femme</label>';
            echo '<input type="radio" id="sexeh" name="sexe"/><label for="sexeh"> un homme</label><br />';
        } else {
            echo '<input type="radio" id="sexef" name="sexe"/><label for="sexef"> une femme</label>';
            echo '<input type="radio" id="sexeh" name="sexe" checked="checked"/><label for="sexeh"> un homme</label><br />';
        }
    }else{
        if (isset($_POST['submit'])) {
            echo '<span class="errorsexe">';
            echo '<input type="radio" id="sexef" name="sexe"/><label for="sexef"> une femme</label>';
            echo '<input type="radio" id="sexeh" name="sexe"/><label for="sexeh"> un homme</label><br />';
            echo '</span>';
        } else {
            echo '<input type="radio" id="sexef" name="sexe"/><label for="sexef"> une femme</label>';
            echo '<input type="radio" id="sexeh" name="sexe"/><label for="sexeh"> un homme</label><br />';
        }
    }
}
?>

This is what can be found in the css file :

span.errorsexe {
  background-color: #ff0000;
}

Problem is, the inspector tells me the span region is of class "errorsexe", but the zone has no red background.

I don't understand what I did wrong. Can you pinpoint my error ?

Thank you.

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149

0 Answers0