【问题标题】:how to send url with get method如何使用get方法发送url
【发布时间】:2018-10-19 13:08:39
【问题描述】:

我有一个这样的表格:

<form method="get" action="sample.php">
    <input type="text" name="url">
    <input type="submit" value="send">
</form>

当我使用 url 提交表单时(如 https://google.com),我的链接是:

site.com/sample.php?url=https%3A%2F%2Fgoogle.com

但我想发送这样的形成网址(不带 https://):

site.com/sample.php?url=google.com

我该怎么做?

【问题讨论】:

  • 你不能这样做其实很好:你(显然是不小心?)阻止了跨站点脚本。
  • 对不起。我编辑我的问题@Loek。我想要这样的网址 site.com/sample.php?url=google.com
  • 好的。那么您只想删除 http:// 和 https:// 还是要完全阻止所有字符的 urlencode? @Majid
  • 是的@AliSheikhpour
  • 这可能是回答这个问题最没用的方法......

标签: php forms get


【解决方案1】:

使用 jquery,您可以在提交之前将 http://https:// 替换为空:

$("form").submit(function(){
   var $input = $(this).find("input[name=url]");
   var cleanValue = $input.val().replace("http://","").replace("https://","");
   $input.val(cleanValue);
});

【讨论】:

    猜你喜欢
    • 2017-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-16
    • 1970-01-01
    • 2011-07-28
    • 1970-01-01
    • 2015-10-10
    相关资源
    最近更新 更多