vendredi 19 février 2016

Elseif not returning the proper value on PHP

When the user introduces a letter and clicks on submit the script shall return a name that starts with that letter, I wrote it using a Switch/Case structure, now I need to write it using if/elseif/else.

The problem is that no matter what letter I introduce on the Textbox I'll always get the return for A (Aberdefia - Anacleto)

$nombrador=$_POST['nombrador'];
$nombrador=strtoupper($nombrador);

if ($nombradorIf = 'A') {
 echo "Aberdefia - Anacleto";
} elseif ($nombradorIf = 'B') {
 echo "Brígida - Brígido";
} else {
echo "Is that even a letter?";
}

The code for the letters C to Z is just like the one for A and B.

Aucun commentaire:

Enregistrer un commentaire