0

Ok so I want to set something up where if an un-subscribed user joins my website they get redirected to a joining page but if they are a subscribed member they stay on the homepage.

<?php
include_once("php_includes/check_login_status.php");
// Make sure the user is logged in and sanitize the session
if(isset($_SESSION['username'])){
    $u = $_SESSION['username'];
} else {
    echo <- Need the code here
    exit(); 
}
?>
Dalton
  • 19
  • 1
  • 7

2 Answers2

0

You can use header() to redirect the user.

header("Location: file.php");

No need to use exit() too.

Lund
  • 272
  • 1
  • 6
0

You can redirect a user by settings a Location header:

header('Location: /newPage.php');

As per the docs calls to header() must be made before any output.

To quote the docs on redirection:

The second special case is the "Location:" header. Not only does it send this header back to the browser, but it also returns a REDIRECT (302) status code to the browser unless the 201 or a 3xx status code has already been set.

juco
  • 6,331
  • 3
  • 25
  • 42