Checkbox not being sent in POST using PHP

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 05:03:30

问题


I have a checkbox and it is not being sent to the call back page using POST. I've read that it needs a value, and I supplied that, but am not sure what else could be wrong. Here's the checkbox code I am currently using. Smarty is being used here.

{foreach from=$all_splash_carriers item=item}
            <tr>
                    <td class="evp">{$item.carrier}:</td>
                    <td><input name="{$item.splash_carriers_id}.splashcarrier.{$item.carrier_id}" value="{$item.url}"/><input type="checkbox"  name="{$item.carrier_id}.checkbox" value="1" {if $item.activated == '1'}checked{/if}/>Activated</td>

            <tr>
{/foreach}

回答1:


The checkbox is not sent if it is not checked.

Also, PHP silently converts any dots in names to underscores, because otherwise the "register_globals" mode would render inaccessible global variables.




回答2:


if $item.activated == '1'

should be

if ($item.activated == '1')


来源:https://stackoverflow.com/questions/15753677/checkbox-not-being-sent-in-post-using-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!