Skip to content

Instantly share code, notes, and snippets.

@PatricNox
Last active May 21, 2019 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PatricNox/15db40b27fe4d69b0169b76e04c534b0 to your computer and use it in GitHub Desktop.
Save PatricNox/15db40b27fe4d69b0169b76e04c534b0 to your computer and use it in GitHub Desktop.
Example: Checkbox with values PHP
<?php
// If they selected the first checkbox!
if (isset($_POST['checkbox_1']) {
echo "You selected: $_POST['checkbox_1']";
}
// If they selected the second checkbox!
if (isset($_POST['checkbox_1'])) {
echo "You selected: $_POST['checkbox_1']";
}
?>
<!DOCTYPE html>
<html>
<!-- You need to wrap this inside a form, for the POST method. -->
<form action="#" method="POST">
<!-- The text inside "name" will be the text inside $POST[] array -->
<!-- while the text inide "value" will be the actual value. -->
<!-- Try change value and see the effect! -->
<input type="checkbox" name="checkbox_1" value="checkbox_1" />
<input type="checkbox" name="checkbox_2" value="checkbox_2" />
<input type="submit">
</form>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment