开发者

Form GET no parameter name

开发者 https://www.devze.com 2023-03-08 18:56 出处:网络
<FORM ME开发者_开发问答THOD=GET ACTION=\"../cgi-bin/mycgi.pl\"> <INPUT NAME=\"town\"><BR>
<FORM ME开发者_开发问答THOD=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.


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消