我需要创建一个链接,点击后将在php中运行:
session_destroy();
Run Code Online (Sandbox Code Playgroud)
我知道如何在html中建立链接,但我不知道如何使它与PHP交互.谢谢你的帮助.
Sta*_*arx 14
例如,您希望使用此脚本进行注销.
对于"index.php",你的HTML必须是这样的(只是一个例子)
<a href="logout.php">Log Out</a>
Run Code Online (Sandbox Code Playgroud)
然后在"logout.php"
session_start(); //to ensure you are using same session
session_destroy(); //destroy the session
header("location:index.php"); //to redirect back to "index.php" after logging out
exit();
Run Code Online (Sandbox Code Playgroud)
如果你想使用JavaScript,我也可以告诉你吗?