php - 用户通知

标签 php javascript html notifications

对用户通知技术感到好奇。指的是简单的东西。例如,用户提交联系表。提交后,用户会看到一条消息,表明表单提交成功。

问题来了。如何在不向 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 libraryDingo Framework .

关于php - 用户通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6239054/

相关文章:

javascript - 如果变量是父类(super class)类型, typescript 不允许子类方法

javascript - ionic 后退按钮未显示在选项卡页面中且动画丢失

internet-explorer - IE 不呈现 div 内容

php - 写入 InnoDB 从 MyIsam 读取

javascript - Qt5-QML-AirLink RV50-JavaScript : How to automatically trigger combobox & button on a third party router

javascript - 画一条线需要使用beginPath()和restore()吗?

javascript - 在onerror函数中重写img标签的onerorr函数

PHP::PDO 多次打开/关闭连接

php - 如何在提交之前预先检查不同 sql 表中的表单值 - symfony

PHP-修复 session 刷新后才生效的问题