User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,999 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,161 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 15732 | Replies: 3
Reply
Join Date: Aug 2005
Posts: 9
Reputation: quansah is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
quansah quansah is offline Offline
Newbie Poster

Help php coding for checkboxes

  #1  
Aug 27th, 2005
i have a form with checkboxes and i was wondering how i could write the php code so that the choices you check can come into my email. here is the html coding for the form:

<form action="<?php echo $me;?>" method="post" name="form1" id="form1">
<p>Name :
<input type="text" name="textfield">
</p>
<p>Course:
<input type="text" name="textfield">
</p>
<p>Tel No:
<input type="text" name="textfield">
</p>
<p>
<input type="checkbox" name="checkbox" value="Judicial Committee">
Judicial Committee<br>
<input type="checkbox" name="checkbox" value="Welfare Committee">
Welfare Committee<br>
<input type="checkbox" name="checkbox" value="External Affairs Committee">
External Affairs Committee<br>
<input type="checkbox" name="checkbox" value="Transport Committee">
Transport Committee<br>
<input type="checkbox" name="checkbox" value="Disciplinary Committee">
Disciplinary Committee<br>
<input type="checkbox" name="checkbox" value="Entertainment Committee">
Entertainment Committee<br>
<input type="checkbox" name="checkbox" value="Publication Committee">
Publication and Information </p>
<p align="center">
<input type="submit" name="Submit" value="Join Now">
</p>
<p align="left"> <br>
</p>
</form>
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2005
Location: Sheffield, UK
Posts: 294
Reputation: zippee is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 6
zippee's Avatar
zippee zippee is offline Offline
Posting Whiz in Training

Re: php coding for checkboxes

  #2  
Aug 27th, 2005
You should change the checkbox names, they are all the same now (each checkbox name has to be unique). PHP code to identify whether a checkbox is checked, use:
[php]if(isset($_POST['checkbox_name'])) echo 'checked';[/php]
Ecommerce-Web-Store.com Building Your e-Business.
Reply With Quote  
Join Date: Jun 2006
Posts: 1
Reputation: Deadly_Killer is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Deadly_Killer Deadly_Killer is offline Offline
Newbie Poster

Re: php coding for checkboxes

  #3  
Jun 16th, 2006
<input name="cd0" type="checkbox" checked="checked">
<?
if(isset($_POST['cd0'])){ echo 'checked';}
?>

dont works, can u help me?
Last edited by Deadly_Killer : Jun 16th, 2006 at 1:57 pm.
Reply With Quote  
Join Date: May 2006
Posts: 9
Reputation: JNathanson is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
JNathanson JNathanson is offline Offline
Newbie Poster

Re: php coding for checkboxes

  #4  
Jun 17th, 2006
Originally Posted by Deadly_Killer
<input name="cd0" type="checkbox" checked="checked">
<?
if(isset($_POST['cd0'])){ echo 'checked';}
?>

dont works, can u help me?

You need to post the form.


myform.php
[PHP]
<form action="check.php" method="POST" name="myform">
<input name="cd0" type="checkbox" checked="checked">
</form>[/PHP]

check.php
[PHP]
<?PHP
if(isset($_POST['cd0'])){ echo 'checked';}
?>
[/PHP]
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 10:06 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC