drugs3550 2014-01-14 13:07
浏览 16
已采纳

在多页表单上使用类

I would like to use Classes in my next website. Part of the site involves a multi-page profile form. The visitor fills in their name, submits this and then fills in their date of birth, submits this and then adds some text.

When the first form is submitted I will instantiate the class and update the database etc but when the visitor submits the next form do I need to declare another "new" class or does it stay instantiated?

What is the recommended way of achieving this kind of behaviour (ie not using classes for this / using sessions to hold the data / instantiating all classes on each page refresh / etc)

Thanks for some direction with this.

  • 写回答

2条回答 默认 最新

  • douchui1488 2014-01-14 13:15
    关注

    As PHP is stateless any classes you initiate only exist for that one page. If you create an instance with data in, it will only exist on that page. If you want it to exist on multiple pages then you will need to reload it on every page.

    For what you're describing it would seem that you would first gather all the data, storing the users answers in session between each page, and then once you have all the answers initiate your class to do whatever it is you want to with your data.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办