[英]Session for holding variables between pages
我正在為我的計算機科學課程制作一個logoquiz,我正忙着用一個頁面向用戶注冊一個帳戶名和電子郵件地址。 成功注冊后,人們將被重定向到index.php
在重定向到的頁面中,有一個綠色框表示注冊已完成,並為其提供進一步說明。
在測試時,每次我訪問index.php時,它都會在電子郵件和用戶名中沒有任何通知。
<!--- Notice itself --->
<?php
session_start();
if(isset($_SESSION)){
$email = $_SESSION["email"];
$username = $_SESSION["username"];
?>
<!--- Green box that pops up --->
<div class="notice success"><i class="icon-ok icon-large"></i> Je registratie is succesvol verzonden <?php echo $username;?><br>
Er is een email verzonden naar <?php echo $email; ?>.<br>
Volg de instucties in deze mail om te kunnen beginnen<a href="#close" class="icon-remove"></a></div>
<?php
session_destroy();
} ?>
在注冊頁面本身(RegSpelers.php)中,此代碼用於會話
<?php }elseif($wrong == FALSE && !empty($_POST)){
// After checking for wrong entered field or nothing at all use session.
$_SESSION["email"] = $email;
$_SESSION["username"] = $username;
header ('Location: index.php');
} ?>
因為
session_start();
$ _SESSION數組存在且isset返回true。
現在也許這就是你在尋找的地方
if(isset($_SESSION['email'])){
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.