我是否正确使用$ _POST ['var']? [英] Am I using $_POST['var'] correctly?

查看:49
本文介绍了我是否正确使用$ _POST ['var']?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我使用的是wordpress,但wordpress社区似乎对严格的PHP或有关这种情况的任何帮助都不了解.

So I'm using wordpress, but the wordpress community doesn't seem to know enough about strict PHP or anything to assist in this scenario.

我有一个名为Gravity Forms的插件,用于创建漂亮的表单/调查表.尽管达成协议,但是它是一个多部分的表单,我不确定如何从第一个到第二个获取所有表单数据.

I've got a plugin called Gravity Forms I'm using to create a pretty elaborate form/survey. The deal is though, it's a multi-part form and I'm not sure how to get ALL the form data from the first to the second.

我可以通过查询字符串传递数据,但是我传递的是25个信息字段,所以它对我来说不太有用.

I can pass data via Query String, but I'm passing 25 fields of information, so it's not quite going to work for me.

一旦提交了form1,我是否可以将其重定向到第二页,其中包含一些代码?

As soon as the form1 is submitted, can I then have it redirect to page two, which has some code in it like

$foo = $_POST['field_1_1']; 

其中field_1_1是前一个表格的输入名称?

where field_1_1 is the name of the input from the previous form?

我之前曾使用$ _GET作为查询字符串,但是我不确定我刚才说的示例是否是如何使用$ _POST

I've used $_GET for query strings before, but I'm not sure if the example I just stated is how to use $_POST

推荐答案

是的,这是正确的用法.只需确保您的表单是使用 POST 方法提交的.

Yes, this is correct usage. Just make sure your form is submitting using the POST method.

只需确保(就像使用 $ _ GET 一样)不信任用户输入.请确保将它们消毒以进行数据库交互.

Just make sure (as you would with $_GET) that user inputs are not to be trusted. Be sure to sanitize them for database interaction.

这篇关于我是否正确使用$ _POST ['var']?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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