CakePHP highly integrated SignUp Form - php

I just wonder how to build up a signup form like this with cakephp 2.x:
A member can have multiple workingtimes and multiple vacationtimes.
There should be one large signup form with one submit button and 3 visually separated areas: memberdetails, workingtimes, vacationtimes.
During signup a member should enter his personal data inside memberdetails and add arbitrary workingtimes as well as arbitrary vacationtimes in the designated areas before hitting the submit button. All the entered times should be listed tabular inside the form before submitting the whole form. At some point the memberdetails, workingtimes and vacationtimes look good and the user submits the form(I know that this is only the ideal situation and there are missing some functions).
My first approach was including the forms for adding workingtimes and vacationtimes inside the members form and send serialized form data via Ajax-POST to the other controller actions (Workingtime->add, Vacationtime->add) and also load the whole related data with something like a crud index function via Ajax and inject the response into the signup form without reloading it. This seems to keep things like validation, security component or the view layout simple, because most of the work will be done by cakephp and not with javascript, but I think it only works if I have allready a database ID for the member - after this I can store workingtimes and vacationtimes. Like allready said, I would prefer one form with one submit button and be able to cancel the whole registration even if there where allready added workingtimes or vacationtimes.
So what is the cake way to achive an integrated form like this? Is it useful to start a transaction and create a dummy member when the form is loading? And then use the ID of this dummy record to store the related workingtimes and vacationtimes? And when hitting the submit button the dummy member is updated to store the entered personal data and everything can be commited? Or should the entered related model data only be validated without saving and then just cache these data for a final transaction block?
Any other ideas?

I think the best approach for this is to manage states. Allow user to enter the basic data, change state, and then you can ask for more information but you will have already a user id to associate and match info. If the user comes back later it will have the current state already.
With Cake, a Component would help you to go from one step to another. Each data you enter should be validated.

Related

Symfony: Order form with option to login to load user details

I've been working on an order form for a type of webshop. I intend to use Craue Form Bundle to split up the form over several pages. At the end of the order, the user is asked for his details (address, phone, ...). However, I also want to give the option to log in at this stage, and then load the user details from the database instead (with the option to change them if they're no longer correct).
Of course, the order process should not be disrupted if the user submits the login form.
How would I do this with Symfony3?
I thought maybe the best idea would perform the login through AJAX
and then fill out the form details when the response comes.
Or I could store the already filled out order details in the session,
but that would require submitting the entire form, not just the login
part of it.
But all this requires deviating from Symfony's way of doing things, which is bound to cause some trouble.
Just wondered if you have any good ideas or ready-made code out there? I seem unable to find anything that suits my needs.

Should we keep User Registration and User Update forms separate

I have a user registration form and a user information update form. All the fields in both the forms are the same. So should I use the same registration form as User update form, on which all the information is fetched from database and is displayed on in the relevant fields. Please suggest me a solution. By the way I am doing all this stuff in Codeigniter.
That's probably not such a good idea, as a user registration form is usually available publicly, but a user update form should be behind a secured area / firewall and you should set up access control for who should be allowed to update a user (eg. only the user themselves and admins).
But if you write your code in such a way that the forms can be reused in different context, then you could use the same code for both pages.

Adding role to user by providing username + mailing + codeigniter ajax

1. Adding role to user
Hello. I am creating my php system that will be used mainly to spread information and managing large database of users.
Let say i have my main "team" settings, and i want to have site where user (admin) can set up team data like "coordinator" or "manager" etc. I want to keep that simple, so admin can set up specific roles (they are stored in database under table team_settings with specific fields like team_manager etc.) by providing username/visible name.
Here is my question. I assume i will need to use jQuery to do simple "quick search" to choose specific user, but here is the deal. How to put this one in my form, that after choosing person, when i post the form i will store user_id in specific table field?
So mainly - how to set up user_id in my field when input will have user name instead?
2. Codeigniter Mailing / Bulk Emails
I am looking for any person that had faced mailing problems while using codeigniter or pure php. My problem is - my shared hosting have 30 sec execution time on PHP scripts, so i need to send email, mobile text message and IM message in this time.
Of course i can use cron to accomplish that, but the question is: Do anyone now any sort of extern API that i can use to send my bulk email? It will be same message (maybe with some variables, nothing more) send to about 150 users maximum.
3. Codeigniter Ajax
I just need to call same methods from my controllers and return different objects - when it is requested by AJAX it should return HTML, but when I call it (or my user) manually, it should load the view. How can i accomplish that?
Thanks in advance for all of your replies.
May The Force Be With You.
Answer for question 3, as I didn't understand the first two.
Simple way of using a function in two different ways:
Send an additinal parameter with ajax request like: ajax=true(either post or get request). when a normal request post/get will be posted, it will not be there. So just have a check that whehter aN ajax named variable exist in post/get request and process data accordingly. IF AJAX FOUND, do not load view, and echo $HTML; else $this->load->view('viewname'); Hope that helps.
After searching the user, when clicking on the edit user are you editing on the same page on a popup or navigating to different page for editing. If you are using same page, store the username in a Javascript global variable and post it while posting other edited details. If you using different page you can pass the username or user_id in the url segment and can use this as a parameter inside the controller function.
http://yoursite.com/controller/functionName/username or id
function functionName($username)
{
//do validate the $username and useit
//if posted update ot display the edit form
}
You can use some email queue concept. Where you insert all the generated emails to a queue table and with status off course. Then process them in a cron job in preferable limit so that it will not exceed the 30second limit. I am have included the same concept for the Codeigniter websites generated using thephpcode.com

User Friendly Registration System

I need to build a registration system which requires the collection of large data (many fields) from the user registering which is then inserted into a couple of tables in a database.
I don't really want to display a very long form to the user for the purposes of better UX.
This system will not run online, it is just a web app to run on the desktop.
I need help, pointers, references, etc on how I can better organize the registration process to make it more user friendly.
This How to encourage a user to fill in long application forms? has been helpful so far
As long as you don't mind requiring your user has Javascript, I would use AJAX. Let's say that you have 50 fields that you can logically combine into 4 different sets - the first may be about the person asking for name, email, etc., while the next set asks for historical information or employment information - like on an application.
Make one form for each set, and then present a new user with the first. When he completes the first page, instead of a "Submit" or "Register" button, use an AJAX call and a "Next" button to get the info and switch to the next page of the form with the next set of fields. You could use the AJAX calls to hold the information in a temp table in your database, and then, once the entire process is complete, you can write it to your member/users table.
You could do like other surveys or checkouts do and add a "title" for each page of the form above the form fields so that as a user moves through registration, they can monitor their own progress.
I'd recommend checking out the Amazon checkout, or really any multi-page survey (you may even be able to set one up yourself on Survey Monkey) to see how a large number of form fields can be broken down logically in a user friendly way.
Hope it helps.
Check out this link: http://www.smashingmagazine.com/2011/05/05/innovative-techniques-to-simplify-signups-and-logins/
It's talking about login- and registration-forms and how to make them more user-friendly. A suggestion which is also included in this article is as follows:
At registration don't ask the user to many questions. Only the basic data like their name for example. Then ask him about more detailed data when the user logs in the first time. This way the registration won't take too long.
Maybe this helps you out :)

How do I control flow of PHP multi-page form?

I am a bit of a PHP newb
I have developed a multi-page form which works fine at the moment - each stage is on another page (I use the session to retain the data).
However I know that users don't always use these forms the way you want!
I want to control the flow of the form.
I would like the user to be able to use the browser back & forward button for ease of use.
They should not be able to skip a part of the form by entering a form stage URL directly into the address bar to get the a later stage in the form (essentially skipping a part of the form).
The form also does not flow the same path every time, it is dependant on the users choices what stage is displayed next.
I was wondering if anyone had any ideas of ways to control the flow of this multi-page form thank you!
store form results in SESSIONS (encrypt them if sensitive)
then just check on each form if the value is set and show it as necessary.
use another session to check the "progress" of the form, to prevent the user from skipping ahead.
for example...
<?php
/* on form 3 */
if(isset($_SESSION['progress'] && $_SESSION['progress']==2)
{
//the second form has been filled out and validates
}
else
{
// the 2nd form hasn't been finished, redirect
}
?>
you could also use like a percentage based system in the session - a value of 90 means that 90% of the form fields have been completed - for displaying "progress" in a visual means to the user.
basically on every form submission, check whats been submitted, if its expected, then set appropiate sessions to redirect to the next stage.
check every set session on every form to determine if the user should be here yet.
Push the data for the non-current fields into a hidden field in the browser (to save time and effort - just serialize an array/object).
I would like the user to be able to use the browser back & forward button
If users are allowed to re-enter previous stages, just let them and rewrite current stage in the session.
If not, make form fields read-only and do not process submitted forms for the previous stages.
That's the only problem I can see here.
You can either use session data to retain the state between multiple pages, or you can transfer all data on each page. Typically you would do the latter with hidden fields or you will create one humonguous form, and use javascript to make it appear as if it was multiple pages, when - in fact - it's not.
There are pros and cons to each solution.

Categories