对用户通知技术感到好奇。指的是简单的东西。例如,用户提交联系表。提交后,用户会看到一条消息,表明表单提交成功。
问题来了。如何在不向 url 附加字符串的情况下(使用 PHP)完成此操作?我问这个是因为我看到越来越多的网站在不使用 url 中的 GET 查询变量的情况下通知用户。
他们是否只是将某些内容存储在某个全局变量中并在读取时读取/取消设置?目前使用哪些技术来实现这一目标?
要进一步添加,在发布和保存表单时:
//The form has been processed, emailed, etc. Now redirect the user back to the page
//We redirect the user so that if they click refresh, the form doesn't re-submit.
//So without a query var in the url, who does the page no that a form was saved?
//Sessions are one solution, what if sessions are not being used?
header("Location:the_original_page.php");
最佳答案
简单:cookie(或 session )。 Cookie 实际上更简单,因为它们的值仅在后续请求中填充,并且它们不会占用您的服务器空间,您也不必依赖 session 。
这种延迟消息通常被描述为闪消息。
我喜欢的一个特定实现是 Note library的 Dingo Framework .
关于php - 用户通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6239054/