Can we publish the value of the “Unverified radio station” button?

I have a situation where I need to turn off the switch value. Is it possible to submit an uncontrolled switch value through a form in php? If so, can you explain?

+4
source share
3 answers

I solved it. I sent both switch values ​​to a hidden field, as well as switch values. Upon receiving the page, I compared the checked value with the hidden field value, and so I got the unverified value. Thanks to everyone who answered my question.

+1
source
<input type="hidden" name="myField" value="false" />
<input type="checkbox" name="myField" value="true" />

, , , , .

, , , . , , , .

+6

sample.php .

<?php
echo "<pre>";
if(isset($_POST['numbers']) && isset($_POST['unchecked']))
{
  $checked_items = $_POST['numbers'];
  $unchecked_items = array_diff($_POST['unchecked'],$_POST['numbers']);
  echo 'Checked Item<br/>';print_r($checked_items);
  echo '<br/><br/>Unchecked Items<br/>';print_r($unchecked_items);
}
?>

<form name='frmname' action='' method='post'>
<input type='radio' name='numbers[]' value='one'/>One
<input type='radio' name='numbers[]' value='two' />Two
<input type='radio' name='numbers[]' value='three' />Three

<input type='hidden' name='unchecked[]' value='one' />
<input type='hidden' name='unchecked[]' value='two' />
<input type='hidden' name='unchecked[]' value='three' />

<input type='submit' name='submit' value='Submit' />
</form>
+1

Source: https://habr.com/ru/post/1532818/


All Articles