Submit webform via URL only?

15,435

Solution 1

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();

Solution 2

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();

Share:
15,435
Shimmy Weitzhandler
Author by

Shimmy Weitzhandler

Updated on June 04, 2022

Comments

  • Shimmy Weitzhandler
    Shimmy Weitzhandler almost 2 years

    I'm not really sure this belongs here, so instead of downvoting just lemme know if so and I'll quickly move it on.

    Anyway, there is a website that has a search page, that when hitting the search button it doesn't include the search query in the URL.

    After searching for something, the page is redirected to ssearch.asp, but as said, the query isn't there.

    My question is if there is a way to submit the search values solely via URL.

    I was wondering if there is a way to fake the search-submit button and post the search term via URL according to form field names.

    The name of the input box is search, so I tried this URL: http://www.torec.net/ssearch.asp?search=query, but it doesn't work, the server returns:

    server error.

    Just to be clear, I'm not looking for a server-side solution, and actually nor for a HTML solution, I just want to be able to paste a plain old URL in my browsers address bar and be there.

    Is this possible?

    Update

    This link doesn't work:
    http://www.torec.net/ssearch.asp?search=dark&page=1

    While this one does:
    http://www.torec.net/ssearch.asp?search=dark&page=2

    Any way to bypass this?

  • Shimmy Weitzhandler
    Shimmy Weitzhandler over 11 years
    Just to be clear, I don't have control of the server, nor of the client, I don't want to use any html, just simple plain old URL only that is pasted in the browsers address bar. Is this possible?
  • Amadan
    Amadan over 11 years
    In a word - no. In several words, technically yes, using a javascript URL.
  • Shimmy Weitzhandler
    Shimmy Weitzhandler over 11 years
    Can you please expand about the js url?
  • Shimmy Weitzhandler
    Shimmy Weitzhandler over 11 years
    The only means I can send users to is plain URL, if that's not possible then the answer is NO...
  • Matthew Dean
    Matthew Dean over 11 years
    I believe he means you would paste this in your address bar: javascript:var a=document.createElement("form");a.method="POST";a.action="h‌​ttp://www.torec.net/‌​ssearch.asp?search=d‌​ark&page=2";var i=document.createElement("input");i.name="search";i.value="q‌​";a.appendChild(inpu‌​t);a.submit();
  • Amadan
    Amadan over 11 years
    @MatthewDean: damn I'm slow... :P
  • Shimmy Weitzhandler
    Shimmy Weitzhandler over 11 years
    @Amadan, lol, Chrome won't accept this length haha, I'll try via goo.gl...
  • Amadan
    Amadan over 11 years
    Chrome will accept it, because I just did it in Chrome. The most limited is IE, at ~2000 characters; most other accept 64KB URLs.
  • Matthew Dean
    Matthew Dean over 11 years
    @Shimmy It is possible to send users to the first page - all they have to do is visit your web page. Read my revised answer.
  • Amadan
    Amadan over 11 years
    Did you note the "must have a page loaded"? Also, it's a hack, therefore "technically yes". If you have any other solution, it'll be better. As you note, it seems they do allow you 2nd page; and 1st page is broken even in their own interface (you can't go back to page 1).
  • Shimmy Weitzhandler
    Shimmy Weitzhandler over 11 years
    You already answered my question, anyway, per my issue: what I'm trying to achieve is add that site to google's search engines so that I can write 'torec.net' in the address bar, and hit tab for search, I tried to replace query with %s in your query, added to chrome search engines but that didn't work :(