[英]passing data from a form to php
Despite this is a common subject, haven't found the answer after a while searching. 尽管这是一个常见的主题,但经过一段时间的搜索并没有找到答案。
I have this html in my view: 我认为这个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>
as you can see, the information captured from the input is sended to an array, which ouput is: 如您所见,从输入中捕获的信息将发送到一个数组,输出为:
array (size=2)
0 => string 'u.status = 2' (length=12)
1 => string 'u.status = 1' (length=12)
what i want to achieve is to name the subkey with a descriptive name, like: 我要实现的是用一个描述性名称来命名子项,例如:
array (size=2)
registered => string 'u.status = 2' (length=12)
notregistered => string 'u.status = 1' (length=12)
shall i send this subkey names directly from the html, or should i make a function in php to do this? 我应该直接从html发送此子项名称,还是应该在php中创建一个函数来做到这一点?
Yes, you can: 是的你可以:
<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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.