954,180 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

php coding for checkboxes

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
                <input type="checkbox" name="checkbox" value="Welfare Committee"> 
                Welfare Committee
                <input type="checkbox" name="checkbox" value="External Affairs Committee"> 
                External Affairs Committee
                <input type="checkbox" name="checkbox" value="Transport Committee"> 
                Transport Committee
                <input type="checkbox" name="checkbox" value="Disciplinary Committee">
                Disciplinary Committee
                <input type="checkbox" name="checkbox" value="Entertainment Committee"> 
                Entertainment Committee
                <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">                
              </p>
		</form>
quansah
Newbie Poster
10 posts since Aug 2005
Reputation Points: 10
Solved Threads: 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:
[php]if(isset($_POST['checkbox_name'])) echo 'checked';[/php]

zippee
Posting Whiz in Training
294 posts since Jan 2005
Reputation Points: 10
Solved Threads: 7
 
<input name="cd0" type="checkbox"  checked="checked">
<?
if(isset($_POST['cd0'])){ echo 'checked';} 
?>


dont works, can u help me?

Deadly_Killer
Newbie Poster
1 post since Jun 2006
Reputation Points: 10
Solved Threads: 0
 

<? if(isset($_POST['cd0'])){ echo 'checked';} ?>

dont works, can u help me?

You need to post the form.


myform.php
[PHP]

[/PHP]

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

JNathanson
Newbie Poster
9 posts since May 2006
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You