seraphpl
seraphpl

Reputation: 23

Form GET no parameter name

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

Upvotes: 2

Views: 2543

Answers (2)

Stephane Gosselin
Stephane Gosselin

Reputation: 9148

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.

Upvotes: 1

koressak
koressak

Reputation: 191

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

Upvotes: 3

Related Questions