Home >Backend Development >PHP Tutorial >How to save the original data after TP framework submits and refreshes?
For example, if the content is illegal, how can I save the data in the text box when refreshing the page after the submission fails? I know how to save it without a framework, but I don’t know how to save it using TP. Is this data also saved in a session? If the submission fails, then output the data to the front end?
For example, if the content is illegal, how can I save the data in the text box when refreshing the page after the submission fails? I know how to save it without a framework, but I don’t know how to save it using TP. Is this data also saved in a session? If the submission fails, then output the data to the front end?
The submitted data can be obtained in the controller, then an error is reported in the controller, and then the data is assigned to the template, which should meet your needs. Also, before submitting the form or ajax in js, store it in localstrage. After the controller reports an error, it is also possible to jump to the template and read data from localstrage.
It is best to let users submit data after verification at the front desk. Of course, server-side verification is essential
The form comes with a function to save data if submission fails! Of course, some form options, such as drop-down boxes, disappear without refreshing.
By verification, do you mean that it must be submitted to the server for verification? Doesn’t the front-end js
do verification? If you have to do verification on the server side and want to save the original data if the submission fails, then render the form again with the failed data, but I think this is not worth the gain. I suggest you directly use ajax
to send data to the server to verify the marriage and return the front-end prompt. This way the user experience is better. Hope it helps you