在php中隐藏的字段 [英] hidden field in php

查看:104
本文介绍了在php中隐藏的字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于隐藏字段,我可以使用类型字段

 < input type =hiddenname = field_namevalue =<?php print $ var;?>/> 

并在GET / POST方法之后以 $ _ GET ['field_name '] / $ _POST ['field_name']?



是否有任何其他方式在php中使用隐藏字段?

解决方案

您绝对可以,我使用这种方法很多,包括JavaScript和PHP。 p>字段定义:

 < input type =hiddenname =foovalue =<?php echo是$ var;?>中/> 

访问w / PHP:

  $ _ GET ['foo']或$ _POST ['foo'] 



<另外:如果他们进入数据库,请不要忘记清理输入。随意使用我的例程: https://github.com/ niczak / PHP-Sanitize-Post / blob / master / sanitize.php



干杯!


For hidden fields, can i use a field of the type

<input type="hidden" name="field_name" value="<?php print $var; ?>"/>

and retrieve it after the GET / POST method as $_GET['field_name'] / $_POST['field_name'] ?

are there any other ways of using hidden fields in php?

解决方案

You absolutely can, I use this approach a lot w/ both JavaScript and PHP.

Field definition:

<input type="hidden" name="foo" value="<?php echo $var;?>" />

Access w/ PHP:

$_GET['foo'] or $_POST['foo']

Also: Don't forget to sanitize your inputs if they are going into a database. Feel free to use my routine: https://github.com/niczak/PHP-Sanitize-Post/blob/master/sanitize.php

Cheers!

这篇关于在php中隐藏的字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆