Welcome Guest, Not a member yet? Register   Sign In
Tansfer variable between views
#1

[eluser]Salim[/eluser]
Hi,

Be cool guys, i'm a newbie in programming...

I'm doing a registration process in 4 steps.

Each step has its own validation process (captcha, valid email ....). I'm using validation and session librairies of CI 1.6.1.

If user gives good info in each step, he will be transfered to the next one.

I want to save the value posted by the user in each step, in order to save them in the database at the end of the registration process.

How can i do that ....??


I'm thinking about this from many days, but i can't solve this myself... I need your help please ....


PS: At the moment, i'm using variable declared in the top of the Registration controller class (attribute of class). The only problem is that it doesn't work if user failed when validating a step... In fact, in that case, all info saved in the variables are lost ...
#2

[eluser]xwero[/eluser]
Create temporary tables copying the tables where the data will be stored in. For each form you store the data in the temp tables when the registration checks out you move the data to the normal tables and delete the temp values. That is the easiest solution.
#3

[eluser]Kromack[/eluser]
Hello i see at least two ways to do this, the first is simply to put hidden fields in your view, wich controllers fill step by step. But I think it would be better to put data in session when you validate one step form.

At the end of your form, you can retrieve all session data of the user (and you can also check if it exists).

I think also there is others ways to do that ^^ (maybe better).

Good luck
#4

[eluser]xwero[/eluser]
The hidden fields can be tampered with so previous validation could be overturned or you have to validate all values in the end but what if there are errors on several forms. I can get messy.

If you use sessions the datalimit of the cookie (4kb) can be exceeded if the forms ask for a lot of data.
#5

[eluser]Salim[/eluser]
Thanks for your quick answers.

Is it a good way to put the data of each steps in session data ?? I mean in term of security ? Should i delete the session at the end of registration to create new session without all these info (because many data will be saved for nothing ...) ?

I think the solution of xwero is better.. But how to retrieve the data from the temp table at the end of registration ...? Using session_id ...?

Thanks in advance,
#6

[eluser]xwero[/eluser]
Sessiondata is a little safer but i wouldn't recommend it. Validate it always if you us it.

You can use the session id or if you generate an id in the first form for the inserted row you can use that.
#7

[eluser]Salim[/eluser]
xwero, If using session data is safer than using database, why don't you recomment it ??
#8

[eluser]xwero[/eluser]
No sessiondata is a little safer than hidden fields. Sorry i wasn't clear about that.
#9

[eluser]Salim[/eluser]
Thanks, that answer to my problem ;-)
#10

[eluser]Kromack[/eluser]
Thank's for you advise xwero.

Using database with temp data seems to be the best way.




Theme © iAndrew 2016 - Forum software by © MyBB