duanke3985 2010-08-24 09:25
浏览 34
已采纳

检测表单字段值是否已被修改

I have a multi-step form which asks the subscriber to check their details before proceeding with the renewal process.

What I want to do is check if the form has been modified from its pre-filled values (extracted from a Web Service) and then write it to my own local MySQL database. This should only happen if the values have been modified from the original.

I know I can do this by using the == operator but I was wondering if there was a more efficient way to do this?

  • 写回答

2条回答 默认 最新

  • druybew06513 2010-08-24 09:29
    关注

    You can do it with (multidimensional) arrays. Name the form/service variables carefully then compare them upon submit with array_diff which tells you which values has been modified. Because you said this is a multi-step form, of course you can collect previously submitted values in a $_SESSION variable too.

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

报告相同问题?