Form GET no parameter name - get

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

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.

Related

SharePoint Redirect after post

My SharePoint input tag is using an XSLT variable for the redirect. I would like to substitute it for a javascript function to determine the value of the users input. Is this possible from within this tag? If not is possible to run a javascript function from within as XSLT variable? The following article show that something like this is possible but I need an example. http://www.nothingbutsharepoint.com/2011/05/05/extending-the-dvwp-passing-xsl-variables-to-javascript-aspx/
Thank you in advance.
<input type="button" id="Submit" value=" Submit " style="width:100px" onclick="javascript: if(!PreSaveItem()) return false;{ddwrt:GenFireServerEvent(concat('__commit;__redirect={',$RedirectLoc,'}'))}"/>
Basically behind GenFireServerEvent is a __doPostBack function.
__doPostBack('elementgeneratedname','__redirect={' + value '}');
Take a look into the browser what code is generated and use it in your function. Most probably first argument is not the id of the button and is the name of the web part container (somthing like 'ctl00$PlaceHolderMain$WebPartId').

Node Express routes - Absolute URL vs Relative URL

I have a simple form of this type
<form name="keywords" action="www.mydomain.com:6161/articles" method="post">
<input type="text" name="keyword" />
<input type="submit" name="submit" value="Submit" />
</form>
The Express 4 routes for handling the form post, is as follows
app.post('/articles', routes.article.keyword);
The actual route file has the following
exports.keyword = function(req,res,next){
res.send(req.body.keyword);
};
Based on the above circumstances, when I post the form in the browser, I see a page “The address wasn’t understood”.
But, if I use relative URL in the form action i.e.,
It works perfect. Why so?
Because in reality, I sometimes may have to post data to a different domain or URL altogether.
I will post my comment as an answer as it helped.
In order for the action to work, you need to either specify full url, that include schema:
<form name="keywords" action="http://www.example.com/articles" method="post">
Or you can just use a relative url:
<form name="keywords" action="/articles" method="post">
a relative path is one not starting with a / (forward-slash)... generally, this will attempt to load from the current url's base dir (you can set this in html, though the browsers default to the 'dirname' of the url (e.g. 'img/something.gif' on a page at '/some/path/index.html' will fetch it from /some/path/img/something.gif').
an absolute path is one starting with a /. it will be loaded using the same schema, host and optionally, port,user, etc (full url syntax: scheme:[//[user:password#]host[:port]][/]path[?query][#fragment]... read more here: https://en.wikipedia.org/wiki/Uniform_Resource_Locator).
a full url is one starting with a schema (http/https/ftp,etc...)... however (this comes in handy): if you're going to be using the same schema (which keeps your site's security score high), you can skip it, along with the colon.
e.g.: while viewing a site from 'https://blah.net', and attempting to load a resource from google (analytics maybe), you can reference it as:
'//google.com/path/to/whatever'
this will use https if the page was loaded over https, or http if not... keeps you from having to determine the scheme that was used when rendering the page.

Is there a way to make <g:link calls POST instead of GET?

I'm using a
<g:link ...
tag for a button that I would like to send as POST instead of GET for security reasons.
Is there a way to do this? I cannot use
<g:actionSubmit
because I'm using Twitter Bootstrap's Glyphicons (i.e. I need to put the icon in between the tag, it can't go in a value attribute)
<g:link class="btn btn-success" action="someAction" id="class.id"> <i class="icon-ok"></i> Save </g:link>
So, I need a link that I can pass the ID as POST and includes a tag structure like:
<g:someTag ... > SOME LABEL </g:sometag>
Thanks for any help on this matter!
Another way is to use g:remoteLink. It defaults to using POST
<g:remoteLink action="someAction" id="${someObj.id}" update="saveStatus">Save</g:remoteLink>
1.My suggestion is to use Ajax before the g:link it self handels the call to the action and controller
like:
<g:link class="btn btn-success" id="class.id" onclick='UsingPost();'>SOME LABLE HERE </g:link>
<script type='text/javascript'>
function UsingPost(){
jQuery.ajax({
type:'POST',
data:{"model":${pleaseUseTheModelyouHaveLoaded}"},
url:'${createLink(action: 'save')}',
success:function(data,textStatus){
jQuery('#success').html(data);},
error:function(XMLHttpRequest,textStatus,errorThrown){}
});
}
</script>
or refer to this post
https://stackoverflow.com/questions/17360606/grails-spring-security-core-ajax-authentication

Passing list as multiple parameter URL in snap

Is it possible to pass list parameter from browser to a handler function in Snap?
How do I construct a multiple parameters URL from a list and send it to a handler function?
For instance, I need to delete some table rows or any other objects.
I can not do it with the usual REST route:
("/objects/:id", method DELETE deleteObject)
simply because there could be too many and deleting 100 rows one by one can get a bit tedious.
I chose the doomed objects via checkbox input, say [3,4,6,8] rows need to be deleted.
So how do I pass that list to the handler within URL and what would route look like for the action ?
UPDATE
Well, I finally did it with jquery and ajax call.
Snap's "getParams" function can process multiple parameters URL but I still cannot figure out how to actually construct the URL without jquery and ajax.
I used javascript to collect the items to be deleted and build the array of the items.
I then used ajax to construct multiple parameters URL and send it to the handler.
Few things to note with this method and Snap:
-- Snaps's "getParams" function only supports old style multiple parameters URL:
"a=1&a=2&a=3&a=4"
and not the new one:
"a[]=1&a[]=2&a[]=3&a[]=4"
which makes passing complex parameters impossible.
-- The route should be:
("/objects/", method DELETE deleteObject)
and not the:
("/objects/:ids", method DELETE deleteObject)
I did not answer my question because I don't believe it is the only way to pass multiple parameters URL with snap.
Although "getParams" can process it, my question still stays: how do I construct the URL and send it off to a handler?
For instance, Rails uses "link_to" function within view logic to construct the URL. Snap does not use any logic inside templates so how does it work then?
It just can't be that the only way to pass multiple parameters URL in snap is with the help of javascript...?
Please someone confirm this for me?
You're pretty much there. The following form...
<form action="/foo">
<ul>
<li>Row 1: <input type="checkbox" name="a" value="1"/></li>
<li>Row 2: <input type="checkbox" name="a" value="2"/></li>
<li>Row 3: <input type="checkbox" name="a" value="3"/></li>
<li>Row 4: <input type="checkbox" name="a" value="4"/></li>
<li>Row 5: <input type="checkbox" name="a" value="5"/></li>
</ul>
<input type="submit" name="submit" value="Submit"/>
</form>
...gets submitted like this.
http://localhost:8000/foo?a=2&a=3&a=5&submit=Submit
Then, inside your handler, this will get you a list of ByteStrings.
fooHandler = do
as <- getsRequest (rqParam "a")
So this doesn't require JavaScript at all. But it works with JavaScript as well. If you use jQuery to submit a list like this...
var fieldData = { rows: [0,1,4], cols: [2,3,5] };
$.getJSON('http://localhost:8000/foo', fieldData, ...);
...then you'll have to make an adjustment for the brackets
rs <- getsRequest (rqParam "rows[]")
cs <- getsRequest (rqParam "cols[]")

How to safely pass an email address through a query string using javascript/php?

I have a form who's data will be submitted to a salesforce.com database via the action parameter
<form name="ifsLeadsForm" id="ifsLeads" action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="post">
Salesforce allows for a return url where the user will be sent after the data is submitted to the database.
<input type="hidden" name="retURL" value="myReturnURL" />
I need to pass the value of the "firstName" input and the "email" input from the form on to the return URL (a php document) so I can $_GET the name and email address and an email can be sent to the user thanking them for submitting their info.
I used the .serialize() function to grab the key/value of the firstName and email inputs and appended them to the return URL:
<script type="text/javascript">
$('#submit').click(function(ev){
var queryString = $('#first_name, #email').serialize();
document.ifsLeadsForm.retURL.value = "http://www.myDomain.com/return.php?"+queryString;
});
</script>
My question is -
Is it safe to be passing an email address through a query string like this? If not, what is the safe way?
I appreciate any help.
Michael
With GET request data is visible to everyone in the URL. POST request is a little safer than GET because the parameters are not stored in browser history or in web server logs.
You have to make ajax request and get it on the server side with $_POST.
More info on http://www.w3schools.com/tags/ref_httpmethods.asp

Resources