$facility=$_POST['兴趣'];
<input type="checkbox" name="interests[]" id="" value="wifi" value="<?php echo in_array('wifi', $facility)??>checked='checked'<?php:;?>" /><label class="check_label">Wifi</label>
<input type="checkbox" name="interests[]" id="" value="spa" value="<?php echo in_array('spa', $facility)?>checked='checked'<?php:;?>"/><label class="check_label">Spa</label>
<input type="checkbox" name="interests[]" id="" value="pet allowed" value="<?php echo in_array('pet allowed', $facility)?>checked='checked'<?php:;?>"/><label class="check_label">Pet Allowed</label>
第二种方法:-
<input type="checkbox" name="interests[]" id="" value="wifi" value="<?php in_array('wifi', $facility){?>checked='checked'<?php}?>" /><label class="check_label">Wifi</label>
<input type="checkbox" name="interests[]" id="" value="spa" value="<?php in_array('spa', $facility){?>checked='checked'<?php}?>"/><label class="check_label">Spa</label>
<input type="checkbox" name="interests[]" id="" value="pet allowed" value="<?php in_array('pet allowed', $facility){?>checked='checked'<?php}?>"/><label class="check_label">Pet Allowed</label>
如果用户犯了任何错误,我会应用这两种方法以保留表单中的帖子值。如果他犯了错误复选框在提交后仍然检查,但它不起作用。