I have 2 php pages. 1st, is for login form and the 2nd php page is the information.
I want the 2nd php page only accessible if the user redirect from the 1st page redirect and prevent the user from accessing it directly.
Let's say the 1st php file called "form.php" and the 2nd php file that I want to prevent direct access called "info.php".
Any suggestions?
So far, see my code below (my code is not working) I got white blank page
Form.php
if(isset($_POST['submit'])){
if((isset($_POST['username']) && $_POST['username'] != '') && (isset($_POST['email']) && $_POST['email'] != '')){
$_SESSION["username"] = $_POST['username'];
$_SESSION["email"] = $_POST['email'];
$loginform = (strlen($_SESSION["username"])>0 && strlen($_SESSION["email"])>0);
if($loginform){
$_SESSION['login'] = 1;
echo("<script>location.href = '/info/';</script>");
}
}
}
info.php
if(!isset($_SESSION['login']){
echo("<script>location.href = '/login/';</script>");
}