stirrah Posted September 15, 2013 Share Posted September 15, 2013 Good day! I'm not sure if this is the right part of the forum. If it's not, feel free to move my thread where it's supposed to be. Anyway... I've followed phpacademy's tutorial for building a login and register system. I want to extend it, but my problem is with how the system is designed. It's a lot of includes...anyone familiar with this tutorial? For example, I want to be able to create a link where the widgets are different from the other pages but the includes makes this tough. I'm not sure how I should do this. Quote Link to comment https://forums.phpfreaks.com/topic/282157-extend-login-register-system-by-phpacademy/ Share on other sites More sharing options...
trq Posted September 15, 2013 Share Posted September 15, 2013 Obviously the tutorial didn't really explain anything well then? Your not likely to get help without a specific question / problem. Quote Link to comment https://forums.phpfreaks.com/topic/282157-extend-login-register-system-by-phpacademy/#findComment-1449526 Share on other sites More sharing options...
stirrah Posted September 15, 2013 Author Share Posted September 15, 2013 I realize I didn't specify what the problem is...hehe, sorry about that. Say we are at produktion.php. In production I have included header.php, and header.php includes widget.php. These three .php files are included on every page to make the site look the same. But when i go to produktion.php I want the widget-page to look different. Right now I'm using this code: <div class="widget"> <?php if ($_SERVER['REQUEST_URI'] === '/produktion.php') { include 'includes/widgets/produktion_widget.php'; } So if I'm currently on that page, It loads a different widget. Is this a good solution or bad? Quote Link to comment https://forums.phpfreaks.com/topic/282157-extend-login-register-system-by-phpacademy/#findComment-1449549 Share on other sites More sharing options...
fastsol Posted September 15, 2013 Share Posted September 15, 2013 Based on what I know of the tutorial, this should be fine. Realistically all you are doing is defining a different include than the system usually uses, which is totally fine to do, it's common practice for such things. The one thing I would change in the code above is how you are checking the url string, the method you are using is open to xss attacks. I would switch it to this instead. if ($_SERVER['SCRIPT_NAME'] === '/produktion.php') I actually define a var at the beginning of my system that strips out the / and .php so I can simply check for the file name alone. It also allows me to add this defined var to an id attribute for the body tag of each page in case I need to make a css change specific to that page as a whole. define ("body_id", basename($_SERVER['SCRIPT_NAME'], ".php")); echo body_id; // This is just so you can see what it returns for the defined above. <head> </head> <body id="<?php echo body_id; ?>"> //Content here </body> Just some examples and methods that allow for greater usage. Quote Link to comment https://forums.phpfreaks.com/topic/282157-extend-login-register-system-by-phpacademy/#findComment-1449557 Share on other sites More sharing options...
stirrah Posted September 15, 2013 Author Share Posted September 15, 2013 Okey, thanks a lot fastsol! I've changed to your code instead. Works like a charm. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/282157-extend-login-register-system-by-phpacademy/#findComment-1449607 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.