1,105,169 Community Members

php coding for checkboxes

Member Avatar
quansah
Newbie Poster
10 posts since Aug 2005
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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>
Member Avatar
zippee
Posting Whiz in Training
294 posts since Jan 2005
Reputation Points: 0 [?]
Q&As Helped to Solve: 7 [?]
Skill Endorsements: 0 [?]
 
0
 

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:

if(isset($_POST['checkbox_name'])) echo 'checked';
Member Avatar
Deadly_Killer
Newbie Poster
1 post since Jun 2006
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 
<input name="cd0" type="checkbox"  checked="checked">
<?
if(isset($_POST['cd0'])){ echo 'checked';} 
?>

dont works, can u help me?

Member Avatar
JNathanson
Newbie Poster
9 posts since May 2006
Reputation Points: 0 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

<input name="cd0" type="checkbox" checked="checked">
<?
if(isset($_POST)){ echo 'checked';}
?>

dont works, can u help me?

You need to post the form.


myform.php

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

check.php

<?PHP
if(isset($_POST['cd0'])){ echo 'checked';} 
?>
You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article