Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

isset returning a '1'

Tags:

html

php

isset

New to PHP, keep that in mind.

My question:

I have a checkbox setup, however when someone clicks a checkbox it returns a '1' instead of the value. How do I fix this?

    <td valign="top">Kies minimaal 1 tijdschrift:</td>
    <td><input type="checkbox" name="gamez" value="gamez" />Stuur mij informatie over het tijdschrijft GAMEZ<br />

$gamez = (isset($_POST["gamez"]) ?
    true : false);

    echo("<tr><td>Tijdschriften:</td><td>$gamez $girls $uitgaan $mode</td></tr></table>");

When I check gamez for instance, it shows: Tijdschriften: 1

like image 456
WobSawd Avatar asked Feb 24 '26 10:02

WobSawd


1 Answers

Of course. You are writing true into it, which is cast to string "1" when you echo it. Write the value in it:

$option1 = (isset($_POST["option1"]) ? $_POST["option1"] : false);
echo("<tr><td>Options:</td><td>$option1</td></tr></table>");

Note that when $_POST["option1"] is not set, $option1 is false, which when echo'd is cast to an empty string.

like image 82
Bart Friederichs Avatar answered Feb 26 '26 23:02

Bart Friederichs



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!