javascript - PHP打开链接然后执行函数
问题描述
我最近开始使用 php 和 mysql 数据库构建登录系统。现在我已经使用 php 代码和用户在引导模式中键入的数据构建了它。
用户打开他的邮箱,单击在数据库中执行验证脚本的链接以将用户设置为已验证并加载我的主站点页面。
之后,我想添加一些模式来告诉类似“您的帐户已验证”之类的内容。什么是正确的方法?我认为它可以通过运行位于index.php
类似的 jquery 函数由 php 完成
<?php
header('location:index.php');
echo "<script> $('#addText').modal();</script>";
?>
但正如我所见,这是不正确index.php
的,php 只是加载,仅此而已。
PS我很抱歉我对php基础知识的无知。
解决方案
如果您使用 HTTP 重定向,页面的内容将被忽略。
相反,您可以使用允许延迟重定向的元刷新标记。
<head>
<meta http-equiv="refresh" content="5;url=https://example.com/index.php" />
<script src="js/jquery.js">
<script> $(function() {$('#addText').modal();})</script>
</head>
5;
表示延迟刷新5秒。
推荐阅读
- python - 使用自定义损失函数运行 Light gbm 时 Python 崩溃
- asp.net-mvc - Automapper 仅将子对象重新映射到现有的扁平化 VM
- python - Matplotlib:来自 3 列熊猫数据框的 pcolormesh 或 pcolor
- ios - Xcode10 随机弹出“无法读取 XCode10Project.app 的包标识符。”
- c# - 为什么在浏览器中手动删除 Anti-forgery cookie 并发布会出现 404(.net core 2.0Razor 页面)
- amazon-web-services - 无法访问函数返回列表中的已处置对象?
- java - 如何自定义适配器以限制要显示的项目
- reactjs - 如何组织 React + MobX 项目结构(存储、组件、组件的状态等)
- webpack - 为什么 vue-cli 有两个 vuejs 启动命令?
- c# - Avalonia UI - 如何从代码中获取/设置 UI 控件的属性