提交表单,隐藏动作属性 [英] Submit form with action attribute hidden

查看:43
本文介绍了提交表单,隐藏动作属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在不显示动作属性的情况下提交表单.像这样

I want to know how to submit form without action attribute shown. Like this

<form action="someact.php" method="post">
...
</form>

有人建议使用 $ _ PHP ['SELF'] ,但是我希望使用另一个php文件来处理表单,例如将UI部分和流程部分分开,以便任何人都看不到我的流程文件?

Some suggest to use $_PHP['SELF'], but I want my form to be processed using another php file like separating UI part and process part so that anyone can't see my process file ?

我想要这样

<form method="post">
...
</form>

但是它处理成了我想要的文件.

But it processed to the file I want.

请帮助?

推荐答案

首先,我不太了解您为什么要这么做. action 属性的全部要点是告诉浏览器将请求发送到何处,并且隐藏"它无法实现任何目的-任何中途熟练的黑客(甚至少于中途黑客)仍然可以无论您做什么,都可以找到您隐藏的信息.

Firstly, I don't quite understand why you would want this. The whole point of the action attribute is to tell the browser where to send the request, and "hiding" it achieves nothing - any half-way competent hacker (or even less than half-way) can still find the information you are hiding, no matter what you do.

话虽如此,您可以执行以下操作:

Having said that, you could do something like this:

<form id="hidden_action_form" method="post">
  <!-- ... -->
</form>
<script type="text/javascript">
  document.getElementById('hidden_action_form').action = 'someact.php';
</script>

这篇关于提交表单,隐藏动作属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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