Laravel 5: Create a multipage registration - laravel

How would I go about creating a multipage registration process in Laravel 5? I know I need to use Middleware, but I don't know how to use it for multiple views.

Add an extra column to your user's table, name it step to keep track of their registration process. Then after every successful form submit increment the step value.
You'd want to signup/register the user in the first step just so if they decide to come back you can redirect them to the correct step/view. This is also useful to remind the users by email to complete their registration.

If you don't use Ajax or any javascript related stuffs to go to the next page without reloading, store the inputs to the session and just get all the data from there.
Else if you're using Ajax/javscript/jquery, just make one big form and send all the data from the inputs.

Related

Registered user First visit url displays flash message

I would like to create middleware and check if registered user has already visited current URL and if not display flash message.
This feature i need just to show up tour on particular page so new user can understand what to do next.
I do realize that i can do it by store data in user table for each user but maybe there is another way to do such thing?
Thank you.
This may go quite complex depending on number of your routes. Why
don't you just make it simple:
1. Whenever user signup just store a session say session()->put('show_tour', true);
2. Now, show the flash-message on every page for registered user by checking this session value.
3. Make a button to disable this tour in your flash message. Make an AJAX call to destroy this session.

How to implement form that requires users to validate email or phone number?

I'm trying to improve this form to make it a little more user friendly.
The main area I'm trying to improve is the validation process.
Right now, the form gets filled out on index page /, and the user is re-directed by the server to a /validate page. To improve the experience, the email or phone number is shown to the user so they can see whether they entered it correctly. (though rarely, it does happen)
I'm also not sure if the user should be given the opportunity to use another form of validation.
The one problem with the setup on the server side is storing the form information between page requests.
Currently I'm using the flash(one-time sessions) to store the email or the phone number. Once the user submits the form the session is lost.
I don't like using sessions for forms, because any time you have more than one window open (not that they should be in this case) the data can start to become unpredictable
I also don't want to use the url params for storing information, as this can have sensitive information being passed back and forth, and stored in browser history.
I was thinking I could do ajax, which I try not to use on sites facing a broad audience where someone is bound to be using an old version of IE.
The data I get from the form is stored in the database. I could use the GET method to store an id in params. If I use the id (or a random unique id) I run the risk of anyone guessing these ids and having access to other website users' email address and phone numbers.
I could also use a combination of the flash and hidden inputs with the unique id, but the danger of showing personal information is still there.

Register Form in several steps

I face a problem with a Form in several step.
I would like create a register form in many steps (3-4), and then save my FOSUser at the last step.
The principle would be to create an empty User in step 1, and fill it part by part until the last step.
My problem is that it's not recommended to store object in session.
So, I wanted to know if Symfony2 proposed an alternative.
You could put the data of the previous steps in hidden fields and submit it with every step again.
Why do you thing saving objects in the sessions is not good? If you write proper serialization handlers this should not be a big problem.
Entites are indeed a bit problematic to store in the session (i had problems with that as well) but you could create a delegate object containing only the user inputs and store that in the session and then after the last step build a symfony user object out of it. Just be sure not to leave masses of unused objects in the session.

How do I pass data across ActionResults in MVC 3?

I have a series of pages that an end user must fill out (check boxes) and when they are finished with each page I attempt to create a List of the check boxes they selected. At the end of the series of pages, I would like to show them everything that they have selected in a confirmation page. I have noticed that between requests the information in the List<> I create on each page is not available to the final confirmation page. I've tried a few different solutions (private globals) to no avail. How would I pass data across ActionResults to accomplish displaying all the selected data on the confirmation page? Thanks.
One potential solution. Others?
The web is stateless, meaning you have to store things if you want to keep them around for later use. That's true for any web framework. You'll need to store each page's results somewhere.
Options for building a wizard:
Store all of the selected answers in session and keep building it up from page to page. The final confirmation would get the results from session.
Store them in a database.
Store results in in a cookie.
Store them in HTML5 local storage
Carry them through on each page with hidden fields. Page 2 would have Page 1's answers in hidden fields, etc.
You need to save a state between the requests. You can do this with:
Query string parameters
Session state
Hidden fields
Db (if you wanna persist the intermediate choices after each request)
Local storage
Cookies
Anything else?
I'd guess, as RyanW points out, that storing them in session state is the usual way to do it. You could however fetch all steps in one request, do some fancy JS / store the intermediary results locally and make a final post when the questionnaire is complete.

Sessions in Codeigniter

I am using sessions to store data from my multi step form so that when the user completes all three sections of the form then the information is inserted in to the database. I have built the form so that the user can go back to any stage and modify the information they have submitted, the thing is though, the values that repopulate the form are stored in sessions so if the user leaves the form page and goes elsewhere in the website and then returns to the form the information is still in the form…is there a better way to do this? I want the data destroyed if they leave the form…
Thanks
Assuming your form exists only in one controller and isn't spread across multiple ones, you could simply unset all session values in the __construct of every other controller. (You could extend the base controller if you have lots to save the hassle of adding this functionality to many.
That way if the user visits another section, the values will be lost, but providing they remain within the "form" they can remain intact.
You could with JavaScript and the unload event, but it'll prove tricky since unload may fire with each "section" of the form.

Resources