Form not submitting programmatically - html

The form here works fine in the browser, but for some reason I cannot submit it programmatically.
If I do not enter anything in the form in the browser then when I submit I get a 'Log-In Error'. But If I try sending a POST request to the form action url (with and without parameters) the response is the same page. Why is this?

You probably aren't accounting for all of the <input /> fields. When serializing the form, I get this list of parameters:
__EVENTTARGET=
__EVENTARGUMENT=
__VIEWSTATE=
UserLoginControl%24districtId=
UserLoginControl%24districtName=
UserLoginControl%24UserName=
UserLoginControl%24UserPassword=
UserLoginControl%24district=
districtId=
districtName=
ScreenWidth=
ScreenHeight=
FlashPlayerVersion=
Make sure you set all of them (or guess and check which ones don't mean anything).

Related

Trying to open a page after submit in a form

I'm trying to add a confirmation page after a submit on a form but i can't figure out why it doesnt work.
I'm working on Prestashop and my action look like that :
<form action="{$urls.pages.contact}" method="post" {if $contact.allow_file_upload}enctype="multipart/form-data"{/if}>
i tried differents things like target="_blank" or action="website.com & {$urls.pages.contact}"
The "action" tag of a form value is the URL where the values of post request are sent. It means that you should have a controller+method which must intercept and process those values at this address (URL, route, call it as you want).
Its not mandatory to do it this way since you can send your data with Ajax, but it's not what you want.
A proper way to do what you want is to set the "action" as a route which refers to a controller::method which process your Post data, then redirect to a page with the Tools::redirect() method.

Submit to HttpHandler results in RequestType GET instead of POST

My ActionHandler.ashx file should be POSTed yet upon entry to ProcessRequest the context.Request.RequestType is always "GET".
Background:
This HttpHandler currently works OK (i.e. clicking a link in an email causes my ActionHandler.ashx to be entered and the querystring is processed correctly). For example:
https://mdwdata/CorporateBrain/ActionHandler.ashx?Action=MarkComplete&ID=1024~nzmewoojgnn&CUID=13
is the URL for the link shown as Mark-Complete in the image just below:
But now I am trying to improve it by following this advice in a previous SO thread :
"In the body of the email, instead of sending a link, include an HTML form that contains a button which performs a postback to your server."
Problem Summary: When I click the Submit button, my handler is entered with verb GET not POST (hence, I have no access to the hidden form data in the Request.Form collection.
Here is a snippet (image) of the email body
If I can get the Submit to post the hidden form variables to my handler, then of course I would remove the links. In the debugger, I verified the form data and it looks good me:
I added this line to my web.config file:
<add path="ActionHandler.ashx" verb="GET,POST" type="System.Web.UI.SimpleHandlerFactory" validate="true" />
Also, my email client is Thunderbird.
What would cause the request to be GET instead of POST?
The short answer to this problem is that Thunderbird does not POST to the URL in the Action attribute of the HTML form tag. Even the newest version of Thunderbird (version 31.2.0) "ignores" the POST and requests the URL via GET.
The construction of the HTML form is properly done and other email clients I have tested work fine:
Microsoft Office 365 Outlook Web App
Google GMail
So, I guess I am doing it "right" but some email clients apparently don't support this (even my favorite which is Thunderbird).

HTML forms - difference between 'action' and the 'next' variable?

According to the HTML book which I am reading (and according to here: http://www.w3schools.com/tags/att_form_action.asp) it says that in the case of forms:
<form action="/login/" method="post">
'action' specifies where to send the form data when a form is submitted. The syntax for it could be
<form action="URL">
Now, in the book I am reading, it also talks about a hidden 'next' variable, like so:
<form action="/login/" method="post">
<input type='hidden' name='next' value='/' />
<input type='submit' value='login' />
The book I am reading states that
The form contains a submit button as well as a hidden field called 'next'. This hidden variable contains a URL that tells where to redirect the user after they have logged in.
From my understanding, doesn't 'action' either way tell specify where to redirect to after the form has been submitted? So isn't having the hidden 'next' variable not necessary because 'action' already tells where to redirect to? Which takes priority if action and next are different URLs? Does it redirect to the URL in action or the URL in next?
First up the action attribute has nothing to do with redirection.
When you click a submit button in a form the browser sends an HTTP request to the server, specificaly to the resource mentioned in the action attribute, using either get or post. What happens next is entirely dependant on what you are using server side.
As far as I am aware the presense of a Next property in the request has no special meaning.
Normally when a form is submitted one of two things will happen
The server does some process then return an HTTP Response. This will show the action url in the address bar of the browser
The server does some processing then redirects the user to a new page. This is usualy programmed by you the programmer and does not happen automagicaly. In php you would use http_redirect(someURL). The next hidden field could be used to hold this URL but it won't do anything with it by itself.
On a technical note, http redirects, be they with asp, php, etc cause, an additional round trip to the browser. So in the case of the redirect above, an HTTP Response is send to the broswser with a header indicating to redirect and where to direct to. The browser will then send a new request to the new location. This is why the new address appears in the browser address bar.
Action url is where the page will be redirected to, by default. The value of next has no effect unless you have server side code to do that. Even if you do write code, the redirect will first go to action url and then to any other url you have changed.

submitting a form that doesn't has an action

I am trying to submit that form on the site from java. up till now i found the POST-DATA that is send using httpFox. but the problem that the form doesn't include an action that i could use. here is the link
http://tamarod.com/index.php?page=english
the data that is sent on submit is
Member_Name=&National_ID=&governerate_id=0&district_id=&Email=&Date_Of_Birth=&Submit=I+Accept
but i tried adding this line beside the url on the browser to try it but nothing happens..
I figured out the problem. I was missing SetDoInput() and SetDoOutput() in my HttpConnection. so i can POST and GET data.

How to submit data from an html page forcing the browser keeps the page unchanged

First let me set the situation.
I am writing a simple client html page and a simple server side program.
In detail, the page has a submit button to POST some data to the server program.
The problem is that any time I test the page to push the submit button ,the browser displays the new page which displays only the return message my server program returned.
How can I modify the html or the server side program so that the browser keeps the page unchanged before after the submit button is pushed.
I know an easiest way ; letting the sever program returns the same string as the client html page.
Thank you in advance.
In a regular form submission, your page will be whatever the server sends back. The form's action might be the same page, and then your server-side code can read the value of any input fields, and set the values in the response back to what they were in the request. This should result in the page looking the same as it did before the submit button was pressed. However, the page has "changed" in the sense that it was reloaded.
Alternatively, your form can make an Ajax request, which means that you'd need to use Javascript to intercept and stop the form submission, and then use additional coding to send the Ajax request, and then receive and process the response.
What you want is probably a postback:
http://en.wikipedia.org/wiki/Postback
1.) AJAX
You could use JavaScript and AJAX to POST the data.
2.) IFrame (not recommended)
You could also create a hidden IFrame and set the target attribute of the form to it.
What you want to do doesn't seem to be very clear.
If you want to submit your POST data without loading a new web page, you can use Ajax. It may be simple to do it in jQuery, and even simpler if you serialize your form data.
$('form').submit(function() {
$.post('your-post-url',$(this).serialize(),function(data) {
alert('Data posted!');
});
return false;
});