Django Form POST with Back button. - html

I am submitting a form using Django. All things went well until I hit back button.
This is the time IE displays "The wab page has expired. "
I have searched a lot, but can not find the exact concept to do it right.
Open page with get request . /user/search/
Post request with form data on the same page /user/search/
[Optional] Either change params and POST
Hit back button.
In both cases you will get webpage Expired. Please guide me how to make this work & avoid the error message?

You shouldn't be using POST for search forms. POST is for actions that change data on the server. Use GET and you won't have this problem.

Related

Is there a way to not show parameters in url

Is there a way to only show a clean url when doing a get request?
i.e. someone is send to a page:
http://domain.com/?param1=1&param2=2
And the user only sees :
http://domain.com
I tried it with a post-request but then you get these annoying pop-ups when someone refreshes the page or hits the back button.
Doing a post-redirect-get is also not possible since this increases the response time to much and the page is generated dynamically so it needs the parameters.
You could use URL rewriting when you are using Apache.
Or similar functionalities in other web servers.
There are 3 ways to pass parameters from a client to a server:
GET request; which you don't want to use
POST body (includes post-redirect-get); you don't wan to use POST
request header
The way to have a client pass arbitrary parameters in a request header is cookies.

Refresh browser without "Confirm Form Resubmission" in perl

I have a perl script that prints out HTML code and runs actions based on user input in the HTML page. I would like to be able to disable the "Confirm Form Resubmission" warning and prevent the users from repeating the last command ran. I saw some posts that solve this issue in php, but not sure how I would do it with perl.
Thanks!
The usual technique for preventing this is the Post/Get Redirect pattern.
This doesn't stop browsers from behaving as they do, but it redirects users to a new page after a successful POST, so that if they refresh they are not repeating the POST, but repeating the GET instead, which doesn't cause a warning.
Here is an example of the flow:
GET "Products/Create"
User types in some information
POST "Products/Create"
Validation fails, re-display the form with warnings - user corrects the input
POST "Products/Create"
Validation passes, item is saved redirect, using a GET to "Products/View/5"
User refreshes the page, this results in a harmless GET "Products/View/5"
To issue a redirect, you can use:
use CGI;
my $query=new CGI;
print $query->redirect('http://www.example.com/newpage');

how to reverse engineer an http API call using REST console

I'm trying to replicate a request I make on a website (ie zoominfo.com) using the same http POST parameters using chrome rest console, but it fails for some reason. I'm not sure if there is a missing field or it's not working because the origin of the request isn't valid.. can someone point me out in the right direction? Below is a detailed explanation of the experiment:
ORIGINAL CASE
basically if I go to zoominfo.com (registered and all) I see a form page that I need to fill:
if I hit enter.. the site makes an ajax call. If I open the chrome web dev tools, and open the network tab, I see the details of the ajax call:
notice the body of the POST has the name John Becker in it:
{"boardMember":{"value":"Include","isUsed":true},"workHistory":{"value":"CurrentAndPast","isUsed":true},"includePartialProfiles":{"value":true,"isUsed":true},"personName":{"value":"john%20becker","isUsed":true},"lastUpdated":{"value":0,"isUsed":true}}
the response is shown under the respones tag:
WHAT I'M TRYING TO DO
basically replicate what i've done above using a REST console (note: so there is nothing illegal here.. i'm just replacing a chrome browser action with a rest client action.. i'm not hacking anyone and i'm not getting information I can't get the normal way, but if someone feels otherwise.. please let me know)..
so I plug in the same parameters as above into the rest console:
now i'm not sure about authentication.. but just to be safe, i entered the same user name and pwd i have for the site into the REST console:
but then I keep on getting an error as a response to my rest console's request:
UPDATE: CORRECT ANSWER:
so according to JMTyler's answer.. I had to simply include criteria in the RAW body, and convert it to url encoding.. in addition to that, I had to explicitly set the encoding in the rest console body..
looking at the chrome inspector more closely, it turns out that I simply had to click on view source:
to get the url-encoded value that I needed to put in the RAW body in the rest console:
I also had to set encoding to gzip,deflate,sdch and things worked fine!
The form is posting all that JSON under the field criteria. You can see this in the screencap of the chrome dev console you posted.
Just start your raw body in rest console with criteria= and make sure the json has been url-encoded. That should do it.
No authentication is needed because none is passed through the headers in your screencap. Any cookies you have when you load the page normally will also be loaded through rest console, so you don't need to worry about explicitly setting them.
Reading your problems I'll make an educated guess:
zoominfo does not provide an RESTful API.
Rest-Console understands and uses HTTP Authentication, which is different from the authentication handler zoominfo implemented.
A possible way to work around may be:
Make a call to the login-page via rest console. you'll get back cookies and a lot more.
In subsequent requests to zoominfo be sure to include those cookies (likely holding some session information) in your request, therefore acting like a browser.

Extra GET Request on META Refresh Redirect (CGI-C)

I have a form (on page form.html) submitting with POST method to a CGI-C page - let's call it form.cgi - and what form.cgi does is it redirects the user to the previous page (to form.html) with appending query strings using HTTP-EQUIV Refresh META after 5 seconds.
However, if I monitor the Web server's access.log although I see the appropriate POST request for form.cgi there is an additional GET request for form.cgi again, after 5 seconds just before redirecting the user to form.html
Has anyone faced with such an issue?
It appears that the answer is on page POST-requesting a location sending Refresh header makes Firefox create GET request but still hold POST data - and <meta> Refresh is deprecated, should not be used at all.

html 4.1 action attribute

Can any one please explain me action attribute do take local disk file and work with get and post method to send and retrieve data back. I want explanation and example both.
Please and thanks for help
Try reading a little bit more about HTML forms and make some tutorials, action is sort of the "link" you are going to send the information of the form to. That "link" can then ask for the information that has been passed to it through the form fields.
Searching in google returned quite a few nice places to start with:
http://www.w3schools.com/html/html_forms.asp
http://www.tizag.com/htmlT/forms.php/
The first link I gave says:
The data is sent to the page specified in the form's action attribute. The file defined in the action attribute usually does something with the received input
and the second one says:
HTML form elements rely on action and method attributes to identify where to send the form data for processing (action) and how to process the data (method)
That is a good point of start. Give them a try, read some more and if you are still having trouble, come back for some more help.