PHP - 隐藏 url (GET) 参数 [英] PHP - hide url (GET) parameters

查看:143
本文介绍了PHP - 隐藏 url (GET) 参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 PHP/HTML 中有一个这样的链接:

I have a link in my PHP/HTML like this:

<a href="http://search.mywebsite.com/login.aspx?checktype=uid&user=adam&password=pass1234&profile=dart&defaultdb=kts"> Log me into this website </a>

当用户点击链接时,参数由第三方网站处理,用户无缝登录.

When users click on the link, the parameters are handled by a 3rd party website which log the users in seamlessly.

是否可以隐藏/屏蔽/伪装网址,以便用户在将参数传递到指定站点的同时看不到参数?

Is it possible to hide/mask/camouflage the url so that users don't see the parameters while still passing them over to the designated site?

如果不是,你们会怎么做?我主要担心用户和密码参数并需要隐藏这些参数.(user=adam&password=pass1234)

If no, how would you guys go about this? I'm mainly worried about the user and password params and need those hidden. (user=adam&password=pass1234)

我知道如何隐藏参数的唯一方法是使用表单发布方法,但在这种情况下,它不是一个选项,因为我使用的是直接链接.

The only way i know how to hide params is when using a form post method but in this case it is not an option because im working with a direct link.

对于那些一直建议使用 POST 方法的人来说,这不是一个选项,因为我没有使用表单并且接收网站不受我的控制.我正在从一个站点登录到另一个(第 3 方)网站

推荐答案

如果您登录的页面由第 3 方控制,您唯一的选择是使用表单和 POST:

Your only option is to use a form and POST if the page your are logging into is controlled by a 3rd party:

<form action="http://search.mywebsite.com/login.aspx" method="post">
   <input type="hidden" name="checktype" value="uid" />
   <input type="hidden" name="user" value="adam" />
   <input type="hidden" name="password" value="pass1234" />
   <input type="hidden" name="profile" value="dart" />
   <input type="hidden" name="defaultdb" value="kts" />
   <input type="submit" value="Log me into this website" />
</form>

编辑:如果它必须是一个链接并且可能需要 javascript,那么您可以使用 javascript 创建并提交一个 动态表单:

EDIT: If it must be a link and javascript can be required then you can use javascript to create and submit a form on the fly:

<a href="#" onclick="postLogin()">Log me into this website</a>

<script type="text/javascript">
function postLogin() {
    var form = document.createElement("form");
    form.setAttribute("method", "post");
    form.setAttribute("action", "http://search.mywebsite.com/login.aspx");

    var params = {checktype: 'uid', user: 'adam', password: 'pass1234', profile: 'dart', defaultdb: 'kts'};
    for(var key in params) {
        if(params.hasOwnProperty(key)) {
            var hiddenField = document.createElement("input");
            hiddenField.setAttribute("type", "hidden");
            hiddenField.setAttribute("name", key);
            hiddenField.setAttribute("value", params[key]);

            form.appendChild(hiddenField);
         }
    }

    document.body.appendChild(form);
    form.submit();
}
</script>

这篇关于PHP - 隐藏 url (GET) 参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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