petenetman Posted July 24, 2010 Share Posted July 24, 2010 I am trying to post a checkbox value form HTML to PHP thus HTML <form> <input type="checkbox" name="IA" value="IA" /> IA Only<br /> </form PHP $_POST['IA']; if($_POST['IA'] !=TRUE){ echo "IA Only Selected" } If I run the page with the above PHP I get an Error 500 - What am I doing wrong? Thanks in advance Link to comment https://forums.phpfreaks.com/topic/208758-html-checkbox-post-to-php/ Share on other sites More sharing options...
Tazerenix Posted July 24, 2010 Share Posted July 24, 2010 not sure for what reason your getting a 500 error. I might just point out that checkboxes pass as "on" or "off" from my experience so that script shouldn't actually display anything (i could be wrong though). Link to comment https://forums.phpfreaks.com/topic/208758-html-checkbox-post-to-php/#findComment-1090588 Share on other sites More sharing options...
petenetman Posted July 24, 2010 Author Share Posted July 24, 2010 Hi, It seems that I can't echo the value of the checkbox in from Html to display in PHP. Can anyone show me some basic code so I can figure it out please? Link to comment https://forums.phpfreaks.com/topic/208758-html-checkbox-post-to-php/#findComment-1090595 Share on other sites More sharing options...
Tazerenix Posted July 24, 2010 Share Posted July 24, 2010 hmm, in your html you've said Value = 'IA', that might be the problem. Here is some code you can try: <form action="phppage.php" method="post"> <input type="checkbox" name="IA" /><br /> <input type="submit" value="Submit" /> </form> phppage.php: <?php if ($_POST['IA'] == "on") echo "checkbox checked"; else echo "checkbox unchecked"; ?> That should work. Link to comment https://forums.phpfreaks.com/topic/208758-html-checkbox-post-to-php/#findComment-1090597 Share on other sites More sharing options...
petenetman Posted July 24, 2010 Author Share Posted July 24, 2010 Thanks Tazerenix I solved it with radio buttons and that seems to work and looks just as good. Can't understand why the checkboxes don't work but thanks for the code. Take it easy! p Link to comment https://forums.phpfreaks.com/topic/208758-html-checkbox-post-to-php/#findComment-1090604 Share on other sites More sharing options...
Tazerenix Posted July 24, 2010 Share Posted July 24, 2010 , we're here to help! Link to comment https://forums.phpfreaks.com/topic/208758-html-checkbox-post-to-php/#findComment-1090606 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.