简体   繁体   English

如何将用户名和密码传递给URL?

[英]how to pass username and password to URL?

I have a login page at work and every day I have to enter user/password. 我在工作时有一个登录页面,每天我必须输入用户名/密码。

I want to write something that could help me use variables to improve my work life. 我想写一些可以帮助我使用变量来改善工作生活的东西。 If I inspect the HTML code I find on the user filed: 如果我检查HTML代码,我会在用户处找到以下内容:

<input data-val="true" data-val-required="The field Username is required" id="Username" name="Username" placeholder="Username" value="" type="text">

And for the password field: 对于密码字段:

<input data-val="true" data-val-required="The field Password is required" id="Password" name="Password" placeholder="Password" type="password">

If I fill value="" with the username and I then I do the same for the password field I can login! 如果我用用户名填写value="" ,然后我对密码字段也可以登录! So value="" is what I need for both field. 所以value=""是我对两个字段都需要的。

But how to pass this HTML code into the URL? 但是如何将此HTML代码传递到URL中呢? My goal is to write a link like <a href="#" target="_blank">Link</a> that will help me login to that URL in a click with already user/password in it. 我的目标是编写一个<a href="#" target="_blank">Link</a>类的<a href="#" target="_blank">Link</a> ,该<a href="#" target="_blank">Link</a>将帮助我单击包含用户名/密码的单击即可登录该URL。

One simple way of extending website is the usage of GreaseMonkey -Scripts. 扩展网站的一种简单方法是使用GreaseMonkey -Scripts。 You could eg add a button on page load which injects the credentials into the values of the form fields: 例如,您可以在页面加载时添加一个按钮,以将凭据注入到表单字段的值中:

window.addEventListener('load', addLoginButton, true);

If the login form has has the method="GET" you can pass the variables in the URL. 如果登录表单具有方法=“ GET” ,则可以在URL中传递变量。 But most certainly the method="POST" is the case. 但是最肯定的是方法=“ POST” In this case there is one fix, you can create a custom webpage which fires an HTTP POST request to the login URL with the required variables set as the username and the password. 在这种情况下,有一个解决方法,您可以创建一个自定义网页,该网页将HTTP POST请求发送到登录URL,并将必需的变量设置为用户名和密码。

You can do this via PHP using CURL . 您可以使用CURL通过PHP进行操作

You were right @Vishwas Chauhan. 你说得对@Vishwas Chauhan。 If I stick this in a HTML file it works: 如果我将其粘贴在HTML文件中,它将起作用:

<form action="http://example.com/" target="_blank" method="post">
<input data-val="true" id="Username" name="Username" value="mybeautifulusername" type="text">
<input data-val="true" id="Password" name="Password" value="mybeautifulpassword" type="password">
<input type="submit" class="button" value="submit" />
</form>

but how can I delete the 2 fields and just keep the "submit" button? 但是,如何删除2个字段并仅保留“提交”按钮? I just need the button and not the 2 fields. 我只需要按钮,而不是2个字段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM