【发布时间】:2014-06-27 14:43:28
【问题描述】:
我正在为我的计算机科学课程做一个徽标测验,我正忙于一个页面,用于使用帐户名和电子邮件地址注册用户。 注册成功后人会被重定向到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()吗?
标签: php session if-statement