homepage Welcome to WebmasterWorld Guest from 54.197.130.16
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
HTML Form Checkboxes and php..
HTML form checkbox php
jon_mcb




msg:1303589
 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




msg:1303590
 4:14 pm on Mar 26, 2003 (gmt 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".

HTH

Allen

jatar_k




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

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

Welcome to WebmasterWorld jon_mcb

Jocelyn




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

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved