HTML form name replaced with wrong symbols - html

I have the following form
<form name="input" action="http://testdomain.com/search/?" method="get" autocomplete="off">
<input type="text" name="?wpv_paged_preload_reach=1&wpv_view_count=1&wpv_post_id=205499&wpv_post_search=">
<input type="submit" id="searchsubmit" value="">
</form>
However the actual URL displays the following search query:
/search/?%3Fwpv_paged_preload_reach%3D1%26wpv_view_count%3D1%26wpv_post_id%3D205499%26wpv_post_search%3D=test
It seems that special symbols such as ? and = are getting replaced with special Encoding characters.
My question is, how do I get the form to not switch my special symbols with the encoding characters?
Thanks

The name of an input element controls the name of one field. The browser doesn’t blindly mash it and its value together and send that to the server. For a GET request, you can include each one as a hidden field:
<form name="input" action="http://testdomain.com/search/" method="get" autocomplete="off">
<input type="hidden" name="wpv_paged_preload_reach" value="1" />
<input type="hidden" name="wpv_view_count" value="1" />
<input type="hidden" name="wpv_post_id" value="205499" />
<input type="text" name="wpv_post_search" />
<input type="submit" id="searchsubmit" />
</form>

Related

form post action going to wrong URL

I have another personal website I want to post my form to, see code
<form name="requestPrint" action="www.mysite1.com/set_var.cgi"
method="POST">
<input name="value" type="hidden" size="8" value="1">
<input type="hidden" name="page" value="mypage.html"/>
<input type="hidden" name="index" value="94"/>
<input type="submit" value ="Print">
</form>
However when the form posts it goes to www.mysite2.com/www.mysite1.com/set_var.cgi
Is there a way to point it to just www.mysite1.com/set_var.cgi?
You should try the following:
action="http://www.mysite1.com/set_var.cgi"

How to send an html form with values filled

Basically i have a html form as string
<form class="form login_form" action="https://app.box.com/api/oauth2/authorize?response_type=code&redirect_uri=http://localhost:8080/&client_id=6n8aeye40bowhwz&state=V8eTbbtXbsV" method="post" name="login_form">
<ul class="container error_container basic_list basic_list_sm hidden"><li class="data plm warning ram pas man"><div class="media pvs"><div class="img icon"><div class="sprite_signup_login_icon_error"></div></div><div class="bd"></div></div></li></ul>
<div class="field_set login_fields fw center">
<div class="login_user_inputs"><label for="login" class="field_label user_login_field">Email Address</label><div class="user_login_field text_input_with_sprite text_input_with_sprite_16x16 mbm"><input id="login" class="text_input login_email ram field_element " name="login" type="email" title="Email Address" placeholder="Email Address" value="email#gmail.com"> <label class="icon" for="login" title="Email Address"></label></div><label for="password" class="field_label user_password_field">Password</label><div class="user_password_field text_input_with_sprite text_input_with_sprite_16x16 mbm"> <input id="password" class="text_input login_password ram field_element" name="password" title="Password" placeholder="Password" type="password" autocapitalize="off" autocomplete="off" autocorrect="off" value="passwordstring"> <label class="icon" for="password" title="Password"></label></div> </div> <div class="login_submit_div"><input class="btn btn-primary mhn login_submit fw pvm ram" title="Authorize" value="Authorize" type="submit" name="login_submit"></div> <input type="hidden" name="dologin" value="1" /> <input type="hidden" name="client_id" value="99hxwc5z7wz" /><input type="hidden" name="response_type" value="code" /><input type="hidden" name="redirect_uri" value="http://localhost:8080/" /><input type="hidden" name="scope" value="root_readwrite manage_groups manage_enterprise_properties manage_app_users manage_managed_users" /><input type="hidden" name="folder_id" value="" /><input type="hidden" name="file_id" value="" /> <input type="hidden" name="state" value="Licg8fhDiFyobsV" /> <input type="hidden" name="reg_step" value="" /><input type="hidden" name="submit1" value="1" /><input type="hidden" name="folder" value="" /><input type="hidden" name="login_or_register_mode" value="login" /><input type="hidden" name="new_login_or_register_mode" value="" /><input type="hidden" name="__login" value="1"><input type="hidden" name="redirect_url" value="/api/oauth2/authorize?response_type=code&redirect_uri=http://localhost:8080/&client_id=99hxwc5z7p9g3z&state=LichV8eTbbtXbsV"><input type="hidden" name="request_token" value="5d6b31164f15f58bebff206db0aa595eaa90f5f9b857860f8ac3e64c85a5b5f4"> <input type="hidden" id="_pw_sql" name="_pw_sql" value=""/>
</div>
<div class="sso_switch option_sso mts pvs phm hidden">
Use Single Sign On (SSO)
Use Box account credentials
</div>
</form>
and now i want to submit this form to the url specified in action parameter of form tag. Same as it will be submitted from a browser. And condition is i should not use beego webserver for this.
Thanks in advance
If I understand you correctly, you have to work with an HTML form as opposed to just the input values, and you want to send the input contained in that form to some other server for processing, and you also want to do this programmatically with Go as opposed to clicking on a button inside a browser.
If I got that right, what you have to do is first get the input values, action url, and method from the form. You can do that by using golang.org/x/net/html for example.
After you have all the necessary values you'll have to encode the input values into a valid application/x-www-form-urlencoded string which you can do using the net/url package.
Then all you have to do is to create an http request with http.NewRequest using the form method and action url as it's first two arguments and the urlencoded string as it's last body argument. (You can use strings.NewReader to turn a string into an io.Reader.)
Finally call http.Client.Do on the http.DefaultClient with the newly created request as it's argument.
It's possible that there are some 3rd party packages that do most of this work for you, so if you want to avoid doing this yourself try searching through github.

Why am I getting a "get" request when it should be a "post" request

I am trying to submit the form below to upload a file, however whenever I submit the form the request coming accross is a 'GET REQUEST'. Is this just my browser being buggy?
<form enctype="multipart/form-data" id="frmUploadDoc2" target="hiddenIframe" method=”POST” action="/rest/wle">
<input id="myFileName" type="file" name="data" />
<input type="text" name="action" value="addDocument" />
<input type="text" name="accept" value="application/json" />
<input type="text" name="parts" value="none" />
<input type="text" name="name" value="myTestQ1" />
<input type="text" name="docType" value="file" />
<input type="submit" value="Submit"/>
</form>
<iframe name="hiddenIframe" id="hiddenIframe" style="display: none;">
Special character quotes might be the culprit:
method=”POST”
Those are ” generated quotes. Replace those with a simple keyboard " (double quote)
Your method argument is using wrong quotes:
method=”POST”
As a consequence the value of method is interpreted as an unquoted value and it’s not POST, it’s ”POST”. The browser doesn’t know how to handle that value and silently replaces it by GET.

Passing parameter and user input

I am trying to pass a few parameter and a user input to a search_form.asp page.
<form action="search_form.asp" method="Post">
<input type="text"name="fname"/></th>
<input type="submit" value="Update">
</form>
And on search_form.asp...
lname=request.QueryString("Lname")
fname=request.form("fname")
But I am unable to see lname when i place Response.Write("<p>Name: " & lname) in search_form.asp
The query string is not preserved when you submit the form, so search_form.asp will not have a query string. As an alternative, could you include the query string as a hidden field:
<form action="search_form.asp" method="Post">
<input type="text"name="fname"/></th>
<input type="submit" value="Update">
<input type="hidden" name="lname" value="<%=Request.QueryString("lname")%>" />
</form>
And then refer to Request.Form("lname") in search_form.asp.
Alternatively, could you include the query string in the form action?
<form action="search_form.asp?<%=Request.ServerVariables("QUERY_STRING")%>" method="Post">
<input type="text"name="fname"/></th>
<input type="submit" value="Update">
<input type="hidden" name="lname" value="<%=Request.QueryString("lname")%>" />
</form>
This should pass the query string on the original page when the form is submitted.

Submitting a hash directly with HTML <form> tag

I need to submit a hash of attributes directly from the form tag. Is this possible?
<form action="/members/1/comments" method="post">
[some element] {"coordinator\_id"=>"1", "time"=>"1230", "info_link"=>"cnn.com"}
<submit>Post</submit>
</form>
This hash should arrive as 'comment' => {"coordinator_id"=>"1", "time"=>"1230", "info_link"=>"cnn.com"}
Almost possible, but not recommended, you should give your values proper names instead, but here is what you asked for:
<form action="/members/1/comments" method="post">
<input name="comment[coordinator_id]" type="hidden" value="1" />
<input name="comment[time]" type="hidden" value="1230" />
<input name="comment[info_link]" type="hidden" value="cnn.com" />
<submit>Post</submit>
</form>