【问题标题】:Passing form variables through URL通过 URL 传递表单变量
【发布时间】:2011-11-03 14:49:15
【问题描述】:

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

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">

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

【问题讨论】:

  • 该表单具有POST,因为它是method,这意味着您将无法通过将查询字符串添加到 URL(GET 请求)来复制它的功能。您需要向 URL 发送 POST 请求。

标签: html forms url http-post http-get


【解决方案1】:

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

【讨论】:

  • 这不是我的网站。那么如何更改表单方法?
  • 哦,我第一次读的时候可能误会了。不确定我是否理解您要做什么:P
  • 好的...我正在尝试使用 urllib 登录cyberoam。但我不知道要传递的确切查询字符串
【解决方案2】:

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

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

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

【讨论】:

  • 你知道这个网站的用户名和密码吗?这是黑客攻击的尝试吗?大声笑你问的关于在 URL 中输入字段的问题,所以我的回答告诉你如何:P
  • 不,这不是黑客攻击。我正在尝试创建一个用于登录该站点的 GUI。所以我需要知道必须传递给服务器的确切字符串
【解决方案3】:

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

【讨论】:

    【解决方案4】:

    <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>

    【讨论】:

    【解决方案5】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-07
      • 1970-01-01
      • 2011-09-25
      • 2016-09-30
      • 2014-12-11
      相关资源
      最近更新 更多