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

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

问题描述

 < a href =http:// search .mywebsite.com / login.aspx的checktype = UID&安培;用户=亚当&安培;密码= pass1234&安培;型材=镖&安培; defaultdb = KTS>将我登入此网站< / a> 

当用户点击链接时,参数由第三方网站处理,

是否可以隐藏/屏蔽/伪装url,以便用户在将它们传递到指定网站时不会看到参数?



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

我知道如何隐藏params的唯一方法是使用表单发布方法,但在这种情况下,它不是一个选项,因为即时通讯工具直接链接。

编辑:
对于那些不断提示使用POST方法的人,这是不是一种选择,因为我没有使用表格,并且接收网站超出了我的控制范围。我从一个网站登录到另一个网站(第三方)

您唯一的选择是使用如果您登录的页面是由第三方控制的,那么您需要一个表单和POST:

 < form action =http: //search.mywebsite.com/login.aspxmethod =post> 
< input type =hiddenname =checktypevalue =uid/>
< input type =hiddenname =uservalue =adam/>
< input type =hiddenname =passwordvalue =pass1234/>
< input type =hiddenname =profilevalue =dart/>
< input type =hiddenname =defaultdbvalue =kts/>
< input type =submitvalue =登录到本网站/>
< / form>

编辑:如果它必须是链接并且可以要求javascript您可以使用JavaScript来创建并提交表单

 < a href =#onclick =postLogin()>登录到本网站< / a> 

< script type =text / javascript>
函数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>


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?

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.

EDIT: To those who keep suggesting using a POST method, this is not an option because I'm not using a form and the receiving website is out of my control. I'm logging in from one site to another (3rd party) website

解决方案

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>

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天全站免登陆