Welcome to WebmasterWorld Guest from 54.147.10.72

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

HTML Form Checkboxes and php..

HTML form checkbox php

     

jon_mcb

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



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("<br>");
echo("" . $_POST['Company'] . "");
echo("<br>");
echo("" . $_POST['var_receive'] . "");
echo("<br>");
echo("" . $_POST['var_deploy'] . "");
echo("<br>");
echo("" . $_POST['comments'] . "");
echo("<br>");

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..

Allen

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

10+ Year Member



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".

HTH

Allen

jatar_k

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

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



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

Welcome to WebmasterWorld jon_mcb

Jocelyn

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

10+ Year Member



An easy way to see what's posted by your form :
<pre>
<?php
print_r($_POST);
?>
</pre>

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

Jocelyn

 

Featured Threads

Hot Threads This Week

Hot Threads This Month