Computers |
|
| | #1 (permalink) |
| Monster Techie | I have a fairly large web site, and just recently added the ability for users to login/store preferences ETC. While that is great, I'm trying to figure out a way to have a nice easy-to-format page, and right now...can't figure a good way to do this! Here's what I'm trying to do... Index.php this page contains all the formatting, normal nav. bar, Etc. And links all other pages to it. Such as... <?php session_start(); $topic=$_GET['topic'] . ".php"; if (!$topic) { $topic="home.php"; } ?> <html> <title>Blah</title> <body> <?php include("nav.php"); include("$topic"); ?> </body> </html> But I'm lost on how to ensure the user is validated on certain pages that are within the page. Since all pages are included...I'm not sure how to control whether the information is shown. I'm using "links.php" as an example, and have been fiddling with it...also for the user/pass, I'm using MySQL...but that part is all good and fine! links.php <?php require("loginrequired.php"); ?> http://www.tech-forums.net loginrequired.php <?php require("config.inc.php"); ?> if logged in, show info (in links.php) { if not, include "login.php". Anyways...I'm pretty sure the part it's getting screwed up is with the multiple php tags in one another, such as: <?php include("links.php") ?> which would turn to... <?php <?php require("loginrequired.php"); ?> http://www.tech-forums.net ?> Ugh, as you can probably guess I'm not very good with this, and would appreciate any suggestions. Also know, the whole point of doing this is to (hopefully) be able to re-design/do any part of it without going into each page and editing the code (such as the login, general site design etc). Thanks...hope this makes sense...!! ![]() |
| | |
| | #2 (permalink) |
| Super Techie Join Date: Apr 2004
Posts: 316
| I'm not familiar with sessions but I imagine you can like check if it's active or if a cookie is stored. If you have includes you can check the session/cookie on each page and a simple if statment can't deny them access if they aren't logged in or allowed. Unfourtunately I don't know sessions or cookies so I can give you an exact answer. |
| | |