Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

HTML Form Checkboxes and php..

HTML form checkbox php



4:01 pm on Mar 26, 2003 (gmt 0)

Inactive Member
Account Expired


In learning PHP while doing.. I decided to throw some troubleshooting code in my php. The script will, eventually, throw all the information from my HTML form in to a MySLQ database.. In the mean time, I threw this code in for troubleshooting purposes:

echo("" . $_POST['ContactID'] . "");
echo("" . $_POST['Company'] . "");
echo("" . $_POST['var_receive'] . "");
echo("" . $_POST['var_deploy'] . "");
echo("" . $_POST['comments'] . "");

To make sure php was passed the correct information. All variables came through correct except 'var_deploy' and 'var_receive', which were blank. These two are checkboxes. What I would like is for php to be passed each checkbox value seperated by commas.

Can someone help me out here? A guy here is trying to get me to use FrontPage... But I like my Notepad..

4:14 pm on Mar 26, 2003 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 14, 2002
votes: 0

Bang the head of the person who's trying to get you to use frontpage against a wall repeatedly until he repents for his sins (assuming it is a him).

Anyway, checkboxes will return blank unless they are checked, in which case they return with a value of "on".



4:22 pm on Mar 26, 2003 (gmt 0)


WebmasterWorld Administrator jatar_k is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 24, 2001
votes: 0

you could test for it
if (!isset($_POST['var_deploy'])) {
$var_deploy = "unchecked";

Welcome to WebmasterWorld jon_mcb

8:49 pm on Mar 26, 2003 (gmt 0)

New User

10+ Year Member

joined:Mar 1, 2003
votes: 0

An easy way to see what's posted by your form :

It can be useful with large forms and tons of data.