Multi step/page form in PHP & CodeIgniter

后端 未结 5 1395
青春惊慌失措
青春惊慌失措 2020-12-20 07:45

I\'m trying to build a multi step/page form in PHP and CodeIgniter and I was wondering if any of you could help me.

How can I have a multi step form in CI that updat

5条回答
  •  攒了一身酷
    2020-12-20 08:04

    Create a unique ID which you use in all steps of your wizard. Save that ID to the database upon the initial saving of your form. Forward this ID to the next steps using a input type="hidden".
    When saving a step, first try to match the ID and, if you find it int the database, perform an update instead of an insert.

    To avoid the "do you want to resend post data", perform each wizard step in two CodeIgniter controller actions:

    • SaveStep5(POST: form instance ID + other "wizards step 5" inputs): looks up the form instance ID in the database and performs insert/update commands; redirects to LoadStep6 and passes the form instance ID in a GET parameter;
    • LoadStep6(GET: form instance ID); looks up the form instance in the database, if the instance is not found: error handling if the instance is found, renders the input form for "step 6"

提交回复
热议问题