944,110 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 48346
  • PHP RSS
Aug 27th, 2005
0

php coding for checkboxes

Expand Post »
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:

PHP Syntax (Toggle Plain Text)
  1. <form action="<?php echo $me;?>" method="post" name="form1" id="form1">
  2. <p>Name :
  3. <input type="text" name="textfield">
  4. </p>
  5. <p>Course:
  6. <input type="text" name="textfield">
  7. </p>
  8. <p>Tel No:
  9. <input type="text" name="textfield">
  10. </p>
  11. <p>
  12. <input type="checkbox" name="checkbox" value="Judicial Committee">
  13. Judicial Committee<br>
  14. <input type="checkbox" name="checkbox" value="Welfare Committee">
  15. Welfare Committee<br>
  16. <input type="checkbox" name="checkbox" value="External Affairs Committee">
  17. External Affairs Committee<br>
  18. <input type="checkbox" name="checkbox" value="Transport Committee">
  19. Transport Committee<br>
  20. <input type="checkbox" name="checkbox" value="Disciplinary Committee">
  21. Disciplinary Committee<br>
  22. <input type="checkbox" name="checkbox" value="Entertainment Committee">
  23. Entertainment Committee<br>
  24. <input type="checkbox" name="checkbox" value="Publication Committee">
  25. Publication and Information </p>
  26. <p align="center">
  27. <input type="submit" name="Submit" value="Join Now">
  28. </p>
  29. <p align="left"> <br>
  30. </p>
  31. </form>
Last edited by peter_budo; Nov 14th, 2011 at 6:06 am. Reason: Adding code tags to old post
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
quansah is offline Offline
10 posts
since Aug 2005
Aug 27th, 2005
0

Re: php coding for checkboxes

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]
Reputation Points: 10
Solved Threads: 7
Posting Whiz in Training
zippee is offline Offline
294 posts
since Jan 2005
Jun 16th, 2006
0

Re: php coding for checkboxes

PHP Syntax (Toggle Plain Text)
  1. <input name="cd0" type="checkbox" checked="checked">
  2. <?
  3. if(isset($_POST['cd0'])){ echo 'checked';}
  4. ?>

dont works, can u help me?
Last edited by peter_budo; Nov 14th, 2011 at 6:06 am. Reason: Adding code tags to old post
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Deadly_Killer is offline Offline
1 posts
since Jun 2006
Jun 17th, 2006
0

Re: php coding for checkboxes

Quote 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]
Reputation Points: 10
Solved Threads: 1
Newbie Poster
JNathanson is offline Offline
9 posts
since May 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
This thread is currently closed and is not accepting any new replies.
Previous Thread in PHP Forum Timeline: yay
Next Thread in PHP Forum Timeline: PHP osDate





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC