Jump to content

HTML Checkbox Post to PHP


petenetman

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.