ugintl Posted November 20, 2015 Share Posted November 20, 2015 I have a website script built with php, html, css and javascript. I want to show custom page to non logged-in/registered users and after they login, they should go to index page or you can say dashboard. Currently a visitor goes directly to index page with login or register options. My website's index.php and template's index.html files are attached. Moreover, I would appreciate if anyone can tell me how can I bootstrap my website (ugintl.move.pk). I guess it is the template which needs to be modified. template folder's snap also attached. Waiting for a helpful reply index.html index.php Link to comment Share on other sites More sharing options...
ugintl Posted November 20, 2015 Author Share Posted November 20, 2015 correction: non logged-in or non-registered users/visitors Link to comment Share on other sites More sharing options...
dsonesuk Posted November 20, 2015 Share Posted November 20, 2015 Since the index.php would be the home page, that is the default page the user will be taken to on entering your domain url address, I would have thought it would be better to have specific content show on index.php depending if logged in or not. Link to comment Share on other sites More sharing options...
ugintl Posted November 21, 2015 Author Share Posted November 21, 2015 Wondering someone can tell me how to do it Link to comment Share on other sites More sharing options...
ugintl Posted November 21, 2015 Author Share Posted November 21, 2015 This is another file that might be of interest. Do we have to make changes in this file? how? Link to comment Share on other sites More sharing options...
justsomeguy Posted November 23, 2015 Share Posted November 23, 2015 It looks like your code uses a framework, so you'll need to figure out how to check if someone is logged in or not. Normally that data is stored in the session but your framework might have a specific way to get that. Link to comment Share on other sites More sharing options...
ugintl Posted November 26, 2015 Author Share Posted November 26, 2015 I guess you should have kept it simple and straight. I found this and it worked. <?php // First execute a common code to connect to the database and start the session require("includes/common.php"); // At the top of the page check to see whether the user is logged in or not if(empty($_SESSION['user'])) { // If they are not, redirect them to the login page. header("Location: login.php"); // Remember that this die statement is absolutely critical. Without it, // people can view your members-only content without logging in. die("Redirecting to login.php"); } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now