Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();//session starts here
- ?>
- <?php
- error_reporting(E_ALL);
- ini_set("display_errors", 1);
- include("connection.php");
- if(isset($_POST['submit']))
- {
- $Mobile=$_POST['Mobile'];
- $Password=$_POST['Password'];
- $check_user="select * from
- UserRegLogs WHERE Mobile='$Mobile' AND Password='$Password'";
- $run=mysqli_query($dbcon,$check_user);
- if(mysqli_num_rows($run))
- {
- echo "<script>window.open('mypage.php','_self'). </script>";
- $_SESSION['Mobile']=$Mobile;//here session is used and value of $Mobile store in $_SESSION.
- }
- else
- {
- echo "<script>alert('Email or password is incorrect!').
- </script>";
- }
- }
- ?>
- <?php
- session_start();
- if(!$_SESSION['Mobile'])
- {
- header("Location: login.php");//redirect to login page to secure the welcome page without login access.
- }
- ?>
- <html>
- <head>
- <title>Registration</title>
- </head>
- <body>
- <h1>Welcome</h1><br>
- <?php
- echo $_SESSION['Mobile'];
- ?>
- <h1><a href="logout.php">Logout here</a> </h1>
Add Comment
Please, Sign In to add comment