Click button -> go to form
Page 1: Form
Page 2 : Form - > submits information from both pages
page 3 -> completion page after form is submitted
I want to stop users from just pressing back and going to the second page. They have to go and click the button to submit a new form .
You should apply this Post/Redirect/Get method to prevent user to go back to 2nd page.
There is specific page to understand the PRG
There is also a way to keep the post data if you need it. You can see from this SO link.
Related
Page one.php has a form with a "Next" button that submits the data to the controller and then redirects to page two.php
On page two.php at the bottom of the form there is a "Previous" button that I want to still save the data but go back to page one.php and also another "Next" button that saves the data and then redirects to three.php and so on.
In Laravel is there a way to do this without duplicating controllers and making it more complicated?
In addition to the buttons there is a navigation menu that would have the same pages so if the user modifies any data they could also click the nav button and then data would be submitted and then go to that next page that they clicked. Is this possible or do I have to have ajax contently listening for form input changes and then posting them to the controller?
Make use of sessions. Store the data in session and on every page check if session var exists. After user submits form, empty the session
https://laravel.com/docs/5.1/session#basic-usage
I'm developing an application in mobile view using CakePHP, where there's no Javascript code can run.
My scenario:
In user login form, users clicked submit button. But before the data submitted and users go to the next page, I make an 'interruption' page (renders a new view). In there, contains "Facebook" and "No, thanks" button. When they click "Facebook", they will connect their Facebook accounts. But, if they click "No, thanks", the login continue.
My question is, how can I make that "No, thanks" button? Because if I use <input type="submit"> button, the form that contain its data is in previous page, so this button will not be clicked. And, how to store POST data, and when that "No thanks" button clicked, then, the data submitted?
You can either store the data in session, or you can make the "no thanks" button the submit button of a form where all the data from the previous page is stored in hidden form fields.
Personally for a number of reasons, I would prefer to utilize sessions, but since you are even asking this question, I am guessing you are unfamiliar with usage of session data.
A simpler question would be:
To make these two forms on single page but with LOTS of vertical or horizontal space in between user login form & 'interruption' page so user seeing the login form can't see interruption section although both are within same <form></form> tag. Then, the the submit button is simply a link to interruption section of the same form. this link is simple an <a> tag with inline linking, which would hide the login form & display interruption page without needing javascript. similar to links to Go to Test Section A on this page
http://www.dynamicdrive.com/dynamicindex5/bookmarkscroll.htm
Further then in the interruption section you can use a real submit button which makes a POST back to request the server.
[edit]
This workaround is based on assumption that user doesn't scroll far enough. Because most users won't, making it 1step process for them instead of 2process which is specially important on mobile. And if somebody does then the empty form gets submitted to the server & then we can run validation & return a error to the user. where he/she can fill the complete form. so This is a good workaround better than storing the data in session & making two POST request for every user login over mobile network which are generally unreliable.
A better solution might be just to combine both forms into one form. Then you don't have to make 2 http requests. Maybe all you need to do is to add one extra button to the original form "Login with FaceBook" next to the other submit button.
I'm using form in a project. In my form, when I click on submit button, the values are submitted properly but after submit if I refresh the page the existing values are inserted again without clicking on button. Please help me out how to submit the button value only on button click not on page refresh.
Use a redirect after page submit to a thank you page.
Header('location: thankyou.php');
exit();
Use the post-redirect-get pattern. http://en.m.wikipedia.org/wiki/Post/Redirect/Get
This means you use POST method on the form, and in the response script you redirect the user to a different page with the location header.
There is a good answer to your question here: How to avoid duplicate when a user click the "refresh" button of his browser?
I am trying to build a web app like this using php, it has two pages:
select.php has some radio buttons in a html form for users to choose. and there is a submit button post the form to a confirmation page.
confirm.php echos the summery from previous page and there is a "back" button allow users to change their selections in the previous page.
In this point, when I hit the "back" button and previous page restored, I would like all my previous selections displayed. (more clearly, if I chose a radio button and submit in select.php, I want the radio button still being chose after I go back to select page by hitting "back" button from confirm.php page.)
Please give me some idea about how to do this kind of restore page thing.
Save your selection in session.
In select.php pre-select the radio buttons if its found in session.
BTW, You should not rely on back button of browser. Create you own back button on confirm.php page. This back button will go to select.php using no history.back()
The HTTP-Protocol is stateless.
So when calling select.php the server doesn't know anything about your previous selection.
You can either save the selection in the session or in a cookie and restore in in selection.php
I have a form with a wysiwyg editor and I would like to add a preview button so the user can see how the content would look like in the website.
In order to do this I inserted another submit button wich gets the info from the form and redirects to a preview page.
All ok, but after clicking that button the form content disappears so the user can see a preview but it has no data in the actual form in order to make some changes or to submit the form in order to save the data.
So here's my question: can I have this preview button and also keep the data in the form after clicking the preview button?
What you need is either:
Repopulate the form from the preview function (that means manually fill in the form with the submitted data)
OR
Use Ajax to submit the form to the preview function and keep open the current edition page.
By the way, you can't have two submit for one form.