来自 php GET 的明确消息
clear message that came from php GET
让我澄清一下。
我有一个 HTML 表单,用于在名为 contact.php
的文件中发送电子邮件
在服务器端,我在发送电子邮件后在 php 中有这个
header('Location:contact.php?co=1'); exit();
在客户端(在包含表单的同一文件中(
if ($_GET['co']) {
echo 'We got it!';
}
因此,用户知道邮件是否已发送。
我怎样才能清除该消息,即"我们明白了"?
我想做一些类似的东西
<input name="mail" type="email" onFocus="cleatThemessage" ><br>
因此,当用户单击表单中的字段时,消息会消失。
谢谢
在header('Location:contact.php?co=1'); exit();
之前
加
$_SESSION['notification'] = "We got it";
和改变,
if ($_GET['co']) {
if(isset($_SESSION['notification']) && $_SESSION['notification'] != '') {
echo $_SESSION['notification'];
unset($_SESSION['notification']);
}
}
为此,我假设您的表单提交到一个页面,例如 saveContact.php插入数据库查询后,您将其重定向到 contact.php?co=1,这样$_SESSION['notification'] = 'We got it'
在插入数据库查询后仅执行一次。
这可能
对你有用:
<?php
if ($_GET['co']) {
echo '<div id="message">We got it!</div>';
}
?>
<input name="mail" type="email" onFocus="document.getElementById('message').innerHTML = '' ;" ><br>
像这样:
Html
<input name="mail" type="email" onFocus="clearThemessage(this)" ><br>
爪哇语
function clearTheMessage(element) {
element.value = "";
}
<?php
if(isset($_GET['co'])){
echo '<p id="gotit">We got it!</p>';
}?>
<input name="mail" type="email" onFocus="removeMessage()" >
<script type="text/javascript">
function removeMessage(){
var el = document.getElementById('gotit');
if(typeof(el) != 'undefined' && el != null){
el.remove();
}
}
</script>
相关文章:
- 使用Mysqli、PHP和AJAX的聊天系统正在将空白消息插入数据库
- PHP 即时消息更新
- php表单验证n在表单上显示消息3秒钟并淡出
- 如何在php中添加按钮而不是错误状态和成功消息
- 使用php-js-msyql的实时更新消息系统
- php函数向XMPP服务器发送消息,不提供日志;不起作用
- 如何使用AJAX、PHP和MySQL发送个人消息
- 如何处理php echo'ajax中的ed消息
- 来自 PHP 的 Dropzone debug 和 ajax 消息
- 如何显示/隐藏 PHP 文件中的 html 消息
- PHP密码脚本和JavaScript刷新冲突,发出我想消除的表单重新提交消息
- Php,如何打开一个小消息/表单窗口(不是新的浏览器窗口)
- 我可以使用 PHP、MySQL 和 Javascript 在我的网站上创建即时消息系统吗?
- 如何使用 javascript 来提醒这些 PHP 错误消息
- PHP 消息未写入日志文件 - tutsplus.com 教程
- 使用 Jquery 删除页面顶部的 PHP 错误消息
- 使用 AngularJS 忽略 PHP 消息
- 使用 JS 错误消息登录 PHP
- 从一个 PHP 脚本发送和显示消息到另一个 PHP 脚本
- 我希望更新未读消息的数量,并在用户收到新消息时播放通知声音.我正在使用PHP,MySql,Javascript