forms - Controlling PHP WebApp State with SESSION -
i'm creating form wizard requires user step through , complete each step before moving on next.
right now, once step validated , completed, switch $_session['step']
next step in line, , check variable when next step loads make sure valid. if user tries skip step out of sequence, $_session['step']
prevents step loading.
is proper approach? also, once step completed, want user able go , edit values entered on given previous step. approach doesn't allow this, i'm not sure how i'd set change session step revisiting without knowing if valid request or not.
any input on appreciated!
there's nothing wrong approach, although might bit limited in doesn't work more 1 form only. however, if 1 small app, no worries.
the second question i'm not sure understand, $_session can accept data type, including arrays, fill $_session , you've done in form far ;
$_session['my_form'] = array ( 'current_step' = 'step_2', 'step_1' = array ( // form elements ), 'step_2' = array ( // form elements ), 'step_3' = array ( // form elements ), 'step_4' = array ( // form elements ), ) ;
next, provide validation @ each point normal. can put little flag each form whether have been filled out or not ;
'step_2' = array ( 'complete' = true, // form elements / fields here ),
another way slice use 1 of many thousands of dynamic forms. example, using jquery, can use accordion plugin (from jquery ui) simulate whole thing in 1 html page.
Comments
Post a Comment