Html 通过 URL 传递表单变量

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7189676/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 10:16:16  来源:igfitidea点击:

Passing form variables through URL

htmlformsurlhttp-posthttp-get

提问by nightf0x

What I want to accomplish is logging in to a website by simply typing in the form variables in the URL.

我想要完成的是通过简单地在 URL 中输入表单变量来登录网站。

HTML code:

HTML代码:

    <form action="httpclient.html" onsubmit="return checkSubmit();" method="post"           target="_parent" name="frmHTTPClientLogin">
    <input type="hidden" name="mode" value="191">
    <label>Username</label>
    <input border="1" style="width:150px" maxlength="60" name="username">
    <label>Password</label></pre>
    <input type="password" border="1" style="width:150px" autocomplete="off" name="password" maxlength="60">

This is the relevant past of the code. Now I want to login to this site http://10.100.56.55/httpclient.htmljust by passing values typed in the url. Firstly is it possible. If yes then what exactly do i need to type for userame :name and password being pass ? and what encoded URL will be passed in POST method if any?

这是代码的相关过去。现在我想通过传递在 url 中键入的值来登录到这个站点http://10.100.56.55/httpclient.html。首先有没有可能。如果是,那么我究竟需要为用户名输入什么:名称和密码正在通过?如果有的话,什么编码的 URL 将在 POST 方法中传递?

采纳答案by mnsr

If you want to type the Querystring in for the username and password, you need to do this in the address field of your browser:

如果要为用户名和密码键入查询字符串,则需要在浏览器的地址字段中执行此操作:

http://10.100.56.55/?username=name&password=pass

EDIT: You need to find out where the form is going and what it's doing. For this, you need to check what the submit javascript function called 'checkSubmit()' is doing. You can do this by opening the page in your browser and doing a view source. If the javascript is external to the html file, check the js links on the page and open those up to find that function. The function might have the querystring parameters you're looking for.

编辑:您需要找出表单的去向以及它在做什么。为此,您需要检查名为“checkSubmit()”的提交 javascript 函数在做什么。您可以通过在浏览器中打开页面并查看源代码来完成此操作。如果 javascript 在 html 文件的外部,请检查页面上的 js 链接并打开它们以找到该函数。该函数可能具有您正在寻找的查询字符串参数。

回答by Marco

Change method="post"to method="get"

更改method="post"method="get"

回答by Indiekoder

<input type="text" class="form-control" placeholder="Products" name="search" value="search" id="search">
<input type="text" class="form-control" placeholder="Products" name="search" value="search" id="search2">
<button type="submit" class="btn btn-default" onclick="location.href='\search.php?search='+ document.getElementById('search').value+'&search2='+document.getElementById('search2').value;"> Search</button>

回答by honeyp0t

It's not possible to do that; the form would have to use the GET method.

这是不可能的;表单必须使用 GET 方法。

回答by javed

the issue was in the input tag <input type="hidden" name="min_price" value="200">forward slash was missing,I have added the forward slash and it works now <input type="hidden" name="min_price" value="200"/>. it was that simple and took alot of time. please dont down vote me I am noob.

问题在于<input type="hidden" name="min_price" value="200">缺少输入标记正斜杠,我添加了正斜杠,现在可以使用了<input type="hidden" name="min_price" value="200"/>。就这么简单,花了很多时间。请不要投票给我,我是菜鸟。