cfhttp通过单击的链接传递POST变量? [英] cfhttp Passing POST variables via a link that is clicked?

查看:211
本文介绍了cfhttp通过单击的链接传递POST变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在查看cfhttp标记,可以使用它通过点击的链接传递变量。

I was looking at the cfhttp tag and it is possible to use it to pass variables via clicked link?

<cfhttp method="Post" url="myurl"> 

我试图在链接点击传递变量(例如,用户ID),但似乎有点不安全通过GET发送...

I am trying to pass variables on a link click (for example, user IDs), but it seems a bit insecure to send via GET...

推荐答案

我的原始答案完全错过了标记,但我不能删除接受答案,因此为了清楚起见,我将更改此答案以符合上述Billy的意见。

My original answer completely missed the mark, but I can't delete an accepted answer, so for the purposes of clarity, I'm changing this answer to agree with Billy's comment above.

CFHTTP用于向其他网站发出服务器端请求(就像您自己访问网站一样),处理该请求的结果,并将其存储在变量中,然后您可以使用该变量来执行其他任务(例如,解析网站的首页以获取特定值)

CFHTTP is for making a server-side request to another website (as if you were visiting the site yourself), processing the results of that request, and storing them in a variable, which can then be used by you to perform additional tasks against (say, the parsing of a website's homepage for specific values).

您要求的内容似乎是完全不相关的功能,其中:

What you are asking for appears to be a completely unrelated piece of functionality, in which:


  1. 您的网页上有一个HTML锚点(超链接)。

  2. 当用户点击该链接时,您希望将1个或多个变量传递到新网页。 / li>
  1. You have an HTML anchor (hyperlink) on your page.
  2. When a user clicks that link, you wish to pass 1 or more variables to a new page.

完成此操作的最简单的方法是使用隐藏表单,然后提交超链接,然后输入form。这符合比利在您的问题的意见中的建议:

The simplest way to accomplish this is to use a hidden form, and have the hyperlink submit then form. This matches Billy's suggestion in the comments for your question:

<form name="myForm" method="post" action="pageToSendVarsTo.cfm">
  <input type="hidden" name="username" value="theuser" />
  <input type="hidden" name="id" value="42" />
</form>

<a href="#" onClick="document.myForm.submit();">the link to click</a>

这里,您有一个HTML表单,其中包含两个隐藏的字段:用户名和ID,页面,因为他们被隐藏(但注意,如果用户查看您的页面的源仍然可以查看)。接下来,点击的链接显示为对用户的超链接。当点击时,JavaScript用于模拟表单提交的触发;它基本上表现为表单具有提交按钮,并且用户点击了提交按钮。这个例子的形式的意思是,用户名和id值然后HTTP POST到你的'pageToSendVarsTo.cfm'页面,他们可以在FORM范围内继续处理。

Here, you have an HTML form with two hidden fields, username and id, which do not display on the page as they are hidden (but take note, can still be viewed if the user views the source of your page). Next, "the link to click" visibly appears as a hyperlink to the user. When clicked, JavaScript is used to simulate the firing of the form submission; it essentially behaves as if the form had a submit button and the user clicked that submit button. What that means for this example's form is that both the username and id values are then HTTP POSTed to your 'pageToSendVarsTo.cfm' page, where they are available in the FORM scope to continue processing.

这篇关于cfhttp通过单击的链接传递POST变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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