将变量发送到其他页面(发送消息)
Send a variable to other page (Send a message)
假设我完成了注册和登录页面,有什么方法可以将变量从注册发送到登录?
我的目标是提醒用户该帐户已创建。它应该如下所示:
Result
您可能想为此使用会话
注册脚本:
//Start session, you need to do this to use session variables
session_start();
//Make the session variable
$_SESSION['message']="Account has been created";
登录页面:
<?php
session_start();
//Checks if the variable is declared, makes sure you don't get a warning for missing variable
if (isset($_SESSION['message'])) {
//You can add whatever CSS class you want to this with "<div class='{Class name}'>". $_SESSION['message'] ."</div>"
echo $_SESSION['message'];
}
//Unset the variable, this makes sure you don't get the message again when you reload, if you're not using sessions anymore session_destroy(); is even better
unset($_SESSION['message']);
假设我完成了注册和登录页面,有什么方法可以将变量从注册发送到登录?
我的目标是提醒用户该帐户已创建。它应该如下所示: Result
您可能想为此使用会话
注册脚本:
//Start session, you need to do this to use session variables
session_start();
//Make the session variable
$_SESSION['message']="Account has been created";
登录页面:
<?php
session_start();
//Checks if the variable is declared, makes sure you don't get a warning for missing variable
if (isset($_SESSION['message'])) {
//You can add whatever CSS class you want to this with "<div class='{Class name}'>". $_SESSION['message'] ."</div>"
echo $_SESSION['message'];
}
//Unset the variable, this makes sure you don't get the message again when you reload, if you're not using sessions anymore session_destroy(); is even better
unset($_SESSION['message']);