I'm making a logoquiz for my Computer Science class, and I'm busy with a page to register users with an account name and email address. After successfully registering people will be redirected to index.php
In the page the are redirected to, there is a green box which says that the registration finished, and gives them further instructions.
When testing, every time I visit index.php, it gives that notice with nothing in the email and username.
<!--- 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();
} ?>
In the register page itself (RegSpelers.php), this code is used for the session
<?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');
} ?>
Because of
session_start();
The $_SESSION array exists and isset return true.
Now maybe this is what you where looking for
if(isset($_SESSION['email'])){
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.