多步/页面形式在PHP& CodeIgniter [英] Multi step/page form in PHP & CodeIgniter
问题描述
我试图在PHP和CodeIgniter中构建一个多步骤/页面表单,我想知道你是否有任何人可以帮助我。
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.
我如何在CI中的多步骤形式,当您返回到上一步与后退按钮更新而不是再次插入?
How can I have a multi step form in CI that updates rather than inserts again when you return to the previous step with the back button? How can I have a form that doesn't have those back button POST form resend messages?
编辑:如果可能,不使用JS
without JS if possible
感谢!
推荐答案
创建一个在向导的所有步骤中使用的唯一ID。在初始保存表单时将该ID保存到数据库。
使用输入类型=隐藏
将此ID转发到后续步骤。
保存步骤时,首先尝试匹配
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:表单实例ID +其他向导步骤5输入):
在数据库中查找表单实例ID,并执行插入/更新命令;
重定向到LoadStep6并在GET参数中传递表单实例ID; - LoadStep6(GET:form instance ID);
在数据库中查找表单实例,
如果未找到实例:错误处理
如果找到实例,则呈现第6步的输入形式
这篇关于多步/页面形式在PHP& CodeIgniter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!