Submit webform via URL only?

倖福魔咒の 提交于 2019-12-01 07:00:40

Sometimes servers conflate GET and POST parameters, as in PHP $_REQUEST hash. However, normally they are separate - and a server that expects its parameters in multipart/form-data might not look at URL at all. In such a case, as it seems to be here, you have to construct a POST request. On the client side you can do it through AJAX or through constructing and posting a form; on the server side, you can use curl, or a library. You did not say what you want to use it for (and where you want to use it), so you just get the general answer, I'm afraid.

EDIT: Here is the JavaScript semi-solution. You have to already be on some page (i.e. can't use it on _blank), and I'm not sure if it works on all browsers.

javascript:d=document;f=d.createElement("form");h=d.createElement("input");f.setAttribute("method","post");f.setAttribute("enctype","application/x-www-form-urlencoded");f.setAttribute("action","http://www.torec.net/ssearch.asp");h.setAttribute("type","hidden");h.setAttribute("name","search");h.setAttribute("value","query");f.appendChild(h);d.body.appendChild(f);f.submit();

Edit: It is not possible to create a link directly to the first page. However, you can easily send a user to the first page by by creating a form:

<form id="postForm" method="post" action="http://www.example.com/search">
    <input type="text" name="search" value="q">
</form>

And then submitting the form whenever the user clicks a psuedo-link:

document.getElementById("postForm").submit();

This can also be done by typing JavaScript code into the address bar:

javascript:a=document.createElement("form");a.method="POST";a.action="http://www.torec.net/‌​ssearch.asp?search=dark&page=2";i=document.createElement("input");i.name="search";i.value="q";a.appendChild(inpu‌​t);a.submit();

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!