2
<FORM METHOD=GET ACTION="../cgi-bin/mycgi.pl">
<INPUT NAME="town"><BR>
<INPUT TYPE=SUBMIT>
</FORM>

Will redirect us to ../cgi-bin/mycgi.pl?town=example

but I want to redirect to ../cgi-bin/mycgi.pl?example

It means, remove the parameter name in the URI?

I try to google, but found nothing like this.

Thanks in advance.

1

2 Answers 2

3

No, you cannot remove the parameter name in standard GET request. Its a common way, how http request are made. All parameters must have a name and therefore it will be a couple (name=value) for each input.

What you are trying to achieve may acomplish javascript processing of the submitted form. Which will take the input named town and redirect user to such URL.

Something like:

<script type="text/javascript">
var elem = document.getElementById("town");
window.location = "path_to_script/mycgi.pl?"+elem.value
</script>

But in html you have to specify your town as following

<input type="text" name="town" id="town" />
Sign up to request clarification or add additional context in comments.

2 Comments

+ oned for making the poster believe this horribly brittle and insecure way of handling http redirection inside a form is actually useful.
I was expecting a little discussion here, not marking it as solved the first time it has been seen. :) Of course this approach is very inadequate and should not be used, unless absolutely necessary. But... it works.
1

GET will always post the variables with query string starting as ?variable=value&variable2=value2"

What you could do is have the form post to itself by removing the ACTION tag, and use method=post. Then parse $_REQUEST['POST'] and build the url you need, and redirect to the built url.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.