Do browsers merge form action querystring params with fields? - forms

Consider this form:
<form method="GET" action="/signup?foo=1">
<input type="hidden" name="bar" value="2"/>
<input type="submit"/>
</form>
Will browsers reliably request "/signup?foo=1&bar=2"?

No.
JS Fiddle suggests Chrome will discard foo=1, and request /signup?bar=2.

Related

FORM POST TO EXTERNAL URL -NEED HTTP BUT ALWAYS IN HTTPS-

In a AURA Lightining component,i need to implement a POST with a FORM, and the target Endpoint is in HTTP and not in HTTPS.
Here the code:
on submitForm:
cmp.find("formFirma").getElement().submit();
The problem is that when i click on button,the browser open the new tab always in https and doesn't find the external resource.
Even if POST should be always in HTTPS,is there a way to this HTTP?
if a do a "GET" with :
'''
var urlEvent = $A.get("e.force:navigateToURL");
urlEvent.setParams({
"url": "http://endpoint"
});
urlEvent.fire();
'''
it works in HTTP.
Thanks
<div onclick="{!c.submitForm}">
<form name="formFirma1" target="_blank" forceSSL="false" aura:id="formFirma" action="http://endpoint" method="POST">
<input type="hidden" name="idVerbale" value="191" />
<input type="hidden" name="CUAA" value="12345AB" />
<input type="hidden" name="TipoUtente" value="Agronomo" />
<lightning:button label="Firma" />
</form></div>
Here is the markup

Combination: Open mailto and form submit

This combination of an open mailto window with a post form to test.php on one click does not work. Any suggestions?
<form id="myForm" action="test.php" method="post">
<input type="hidden" name="someName" value="helloworld" />
<a href="mailto:..."
onclick="document.getElementById('myForm').submit();">
Submit
</a>
</form>
Check below solution to ignore href attribute and focus on using onclick only to do what you need
function submit() {
window.open('mailto:mail#example.org', '_blank');
document.getElementById('myForm').submit();
return true;
}
<form id="myForm" action="test.php" method="post">
<input type="hidden" name="someName" value="helloworld" />
<a href="#" onclick="return submit();">
Submit
</a>
</form>
And if you need to use both href and onclick check below alternative solution
function submit() {
document.getElementById('myForm').submit();
return true;
}
<form id="myForm" action="test.php" method="post" onsubmit="alert('Ok')">
<input type="hidden" name="someName" value="helloworld" />
<a href="mailto:mail#example.org" target="_blank" onclick="return submit();">
Submit
</a>
</form>
#Wael: Thanks. The second solution is equivalent to this.
<form id="myForm2" action="test.php" method="post">
<input type="hidden" name="someName" value="helloworld" />
Submit 2
</form>
The missing target attribute was the issue.
In Firefox it works as required. In Chrome it leads to
1. Opens the mail client
2. Posts to test.php
3. Opens a new browser tab with url mailto:mail#example.org (and focus)
With your first solution it is the same. How to avoid 3.?

SEO Url not changing upon form submission

Am using SEO URls to load my pages ie http://www.mywebsite.com/p/page1/100 but am having a problem with my search form. When I click submit, instead of the entire url changing to the stated one in the form, it just appends the variables to the url eg http://www.mywebsite.com/p/page1/100?p=search&q=Any+Query+String+here.
My question is, how do I replace the entire URL with the form variable instead?
Here is my form code:
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="get">
<input type="text" onfocus="if(this.value==this.defaultValue) this.value='';" onblur="if(this.value=='') this.value=this.defaultValue;" name="q" value="Search" />
<input type="hidden" value="search" name="p" />
<input type="submit" value="Search" class="submit" />
</form>
OK I solved it using a hack I think???
Apparently if I append a variable to the action url, this will force the browser to load the new url instead of append the form variable to the existing url.
Eg.
<form action="<?php $_SERVER['PHP_SELF'] ?>?p=search" method="get">
<input type="text" onfocus="if(this.value==this.defaultValue) this.value='';" onblur="if(this.value=='') this.value=this.defaultValue;" name="q" value="Search" />
<input type="hidden" value="search" name="p" />
<input type="submit" value="Search" class="submit" />
</form>
This worked for me but I dunno if it's the right way to achieve this or it's a hack.

posting data using html in iphone

In website the form data is posted using the code below using HTML post request:
<div id="requestinfo">
<form method="post" action="http://abc/form-post.php" id="request_form">
<input type="hidden" name="field1" value="value1" />
<input type="hidden" name="field2" value="value2" />
</form>
</div>
How can I do the same in iPhone? We do not have to use web services.
I'd recommend using AFNetworking as a solution for working with HTTP verbs and data.
The AFHTTPClient allows you to specify the verb (POST in this case) as well as the parameters to pass.
See: AFNetworking Post Request

Why is JBoss Post Form sending parameters in URL?

Our JBoss form is posting the parameters in the URL instead of in the request despite being a POST form. I have confirmed that the form is post in the actual page using Firebug. Note that this is within a portlet.
We are submitting the form using javascript like:
function submitForm(action, time)
{
document.getElementById("pageActionInputID").value = time;
document.getElementById("timeSpanFormInputID").value = action;
document.getElementById("formID").submit();
}
<form action="<portlet:actionURL></portlet:actionURL>" method="POST" id="formID">
<input type="hidden" name="pageAction" id="pageActionInputID" />
<input type="hidden" name="timeSpan" id="timeSpanFormInputID" />
</form>
where 'portlet' is from
<%# taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
Any ideas why we are getting the inputs in the URL?
Here is what the resulting markup looks like:
<form id="formID" method="post" action="/portal/auth/portal/myTab?action=1">
<input id="pageActionInputID" type="hidden" name="pageAction"/>
<input id="timeSpanFormInputID" type="hidden" name="timeSpan"/>
</form>
Though it would be great if someone could confirm it. I think the JBoss Portlet throws out post/get and uses action URLs instead.
A descriptive article about render and action URLs