In my html - I have a single checkbox - which looks like this:
<input type="checkbox" name="subscribed" id="subscribed" value="sub_me">
In my PHP, I've created a variable $subscribe
which links to the subscribed
checkbox.
The PHP is supposed to send an email of "I would not like to recieve news emails"
when the checkbox is left alone. To achieve this I have opted to use the following ternary inside the PHP form validation code:
$subscribe = 'would '
. ($_POST['subscribed'] === 'sub_me'?'like to ':'not like to ')
. 'recieve news emails.';
The problem is that, when the checkbox has been selected and the form submitted, I get an email which says
I would not like to recieve news emails.
I could always just use a regular if/else
style code to achieve my goal, however I would like to know what's the problem with this.
Aucun commentaire:
Enregistrer un commentaire