Home > Uncategorized > PHP Tutorial - checkbox form

PHP Tutorial - checkbox form

February 5th, 2012

Let us assume that you want to present a user with two or more than 2 choices and want him to take action based upon one or more selections he makes in the checkboxes.

To give you more exact example look at the following picture, where you are presented to choose one or more programming languages that you like.

Let us say you choose PHP and Javascript

If you hit the submit button the program should give the output something similar to

Here is the example code to do it.
<form action="check_programs.php" method="post">
Which Programmming Languages do you like ? <br />
<input type="checkbox" name="chsarp" value="No" /> Csharp <br />
<input type="checkbox" name="php" value="Yes" /> PHP <br />
<input type="checkbox" name="javascript" value="Yes" /> Javascript<br />
<input type="submit" name="checkform" value="Submit" />

if (isset($_POST['checkform']))

if  ($_POST['csharp'] == 'Yes')
echo "You like csharp"; echo "<br />";

if  ($_POST['php'] == 'Yes')
echo "You like PHP";echo "<br />";

if  ($_POST['javascript'] == 'Yes')
echo "You like javascript"; echo "<br />";


You may like to check PHP Tutorial, if you are looking for getting started.



  1. No comments yet.
  1. No trackbacks yet.