Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将数据从表单传递到php_Php_Html_Arrays_Checkbox - Fatal编程技术网

将数据从表单传递到php

将数据从表单传递到php,php,html,arrays,checkbox,Php,Html,Arrays,Checkbox,尽管这是一个常见的话题,但经过一段时间的搜索,我还是没有找到答案 我的视图中有以下html: <div class="control-group"> <label class="control-label">Tipo de Socio</label> <div class="controls"> <label class="checkbox line"> <input type="checkb

尽管这是一个常见的话题,但经过一段时间的搜索,我还是没有找到答案

我的视图中有以下html:

<div class="control-group">
 <label class="control-label">Tipo de Socio</label>
    <div class="controls">
      <label class="checkbox line">
        <input type="checkbox" id="registered" value="registered" name="type[]" /> Registrado
      </label>
      <label class="checkbox line">
        <input type="checkbox" value="notregistered" name="type[]"/> Pre-Registrado
      </label>
    </div>
</div>
我想要实现的是使用描述性名称命名子键,如:

  array (size=2)
  registered => string 'u.status = 2' (length=12)
  notregistered => string 'u.status = 1' (length=12)
我应该直接从html中发送此子项名称,还是应该在php中创建一个函数来执行此操作?

是的,您可以:

<div class="control-group">
 <label class="control-label">Tipo de Socio</label>
    <div class="controls">
      <label class="checkbox line">
        <input type="checkbox" id="registered" value="registered" name="type[registered]" /> Registrado
      </label>
      <label class="checkbox line">
        <input type="checkbox" value="notregistered" name="type[notregistered]"/> Pre-Registrado
      </label>
    </div>
</div>

蒂波德社会
登记处
预注册

是的,我在问是否可以从html表单的内部数组中命名密钥
<div class="control-group">
 <label class="control-label">Tipo de Socio</label>
    <div class="controls">
      <label class="checkbox line">
        <input type="checkbox" id="registered" value="registered" name="type[registered]" /> Registrado
      </label>
      <label class="checkbox line">
        <input type="checkbox" value="notregistered" name="type[notregistered]"/> Pre-Registrado
      </label>
    </div>
</div>