surelyoujest Posted January 16, 2009 Share Posted January 16, 2009 I'm creating a system of templates for my website. My index.php file is essentially the frame for all the site's content. Each link on the site directs the user to index.php while attaching a value to the variable $content: [pre]http://www.domain.com/index.php?content=value[/pre] which then plugs into this: [pre]<?php if (empty ($content)) { require 'templates/body.html'; } else { require 'templates/$content.html'; } ?>[/pre] In theory, this should load value.html into the layout of index.php, while using body.html as a default if $content is empty. Instead, body.html is the only thing that loads. In other words, it seems as if $content refuses to take on any value. This procedure worked perfectly on a website I did for a client, but it's being very rebellious against my own website. I should mention that the "templates" folder and all the files therein are properly uploaded and named. Your thorough criticism--and your patience with a PHP noob--is greatly appreciated. Thanks, surelyoujest Link to comment https://forums.phpfreaks.com/topic/141119-problems-with-require/ Share on other sites More sharing options...
rhodesa Posted January 16, 2009 Share Posted January 16, 2009 you are probably used to register_globals being on, which is no longer the default (and shouldn't be for security reasons) try this: <?php if (empty ($_GET['content'])) { require 'templates/body.html'; } else { require 'templates/{$_GET['content']}.html'; } ?> note: this should get your script working...but it too is very flawed when it comes to security. someone could put something in the url that would allow them access to pages they shouldn't have access to Link to comment https://forums.phpfreaks.com/topic/141119-problems-with-require/#findComment-738592 Share on other sites More sharing options...
surelyoujest Posted January 16, 2009 Author Share Posted January 16, 2009 That seems to work. I'll use that for now and work on security in the meantime. Thanks. Link to comment https://forums.phpfreaks.com/topic/141119-problems-with-require/#findComment-738612 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.