php表单中,服务器端验证失败,需要检索输入的表单数据进行显示
我有两种形式,第一种形式的数据被发送到第二种形式。
在将第一个表单数据发送到第二个表单之前,它会在服务器上进行验证。
第一个表单数据包含大量信息,因此在验证失败时,用户需要因为一个小错误而重新输入所有数据。
那么,是否有任何解决方案可以在表单中预先填写验证失败的数据,以便用户轻松填写缺失的数据呢?
我在 ZEND 框架和 MVC 架构中使用 PHP 和 MySQL,但无法使用 Zend_Form。
I have two forms where the data from the first is being sent to the second.
Before the first form data is sent to the second form it is validated on the server.
The first form data consists of a lot of information, so on validation failure, the user needs to enter all the data back again because of a small mistake.
So, is there any solution to pre-fill the form with data on validation failure, so that it makes user comfortable to just fill in the missing data?
Im using PHP with MySQL in ZEND framework and MVC architecture, but I am unable to use Zend_Form.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您使用 Zend_Form 类,则在表单中出现失败的发布请求后,所有数据都应自动填充。下面的示例代码:
If you use a Zend_Form class all data should automatically populated after post request with failures in form. Below example code:
这是一个简单的方法。还有其他方法可能与您现有的代码更加集成,并且取决于您的会话管理,好吧,如果您以向导方式等继续进行购买篮安排,事情可能会变得更加复杂。
请记住 - 这在这里很简单,如果您使用数据库,那么相关查询可能会更复杂。
===编辑注释
将 if($k=='') 更改为 if($$k=='')
this is a simple method. there are other ways that may be more integrative with your exisiting code and depending on your session management, well, if you are continuing a purchase basket arrangement as in a wizard fashion etc, things can get more complex.
bear in mind - this is simple here and if you have db use then it can be more complicated regarding related queries.
===EDIT NOTE
changed if($k=='') to if($$k=='')