shag Posted October 20, 2007 Share Posted October 20, 2007 Basically I have an admin area in /admin. Once going there it will check to see if you are logged in, and if not show the login page. Once you provide valid login details it shows the main admin area. I have no problem simply doing echo "Admin area"; etc... But I want it to be styled to look like the rest of my website. My index.php is <? session_start(); include("database.php"); include("login.php"); ?> <html> <link media="screen" href="style.css" type="text/css" rel="stylesheet"> <title>Admin Are</title> <body> <? displayLogin(); ?> </body> </html> I saved the whole html layout of how i want the site to look as "style.txt" in login.php I have: $template = file_get_contents("style.txt"); Then further down after it decides whether the user is logged in and if they are logged in i have: function displayLogin(){ global $logged_in; if($logged_in){ echo $template; } else{ display login form again... Any advice on how I can style the admin area? Or see an area where i mixed something up? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/74020-solved-echoing-a-file-content/ Share on other sites More sharing options...
Ninjakreborn Posted October 20, 2007 Share Posted October 20, 2007 to be honest it looks as if your doing unnecessary work. I suggest just attaching the css file like normal. a .txt file is not going to do anything, put it in a .css file and just include it where you want the files to go. Quote Link to comment https://forums.phpfreaks.com/topic/74020-solved-echoing-a-file-content/#findComment-373650 Share on other sites More sharing options...
shag Posted October 20, 2007 Author Share Posted October 20, 2007 I understand what you are saying, but in order to add the content I want would I not have to go through the 400+ lines of html code and echo it all?? Or how would I go about that? Quote Link to comment https://forums.phpfreaks.com/topic/74020-solved-echoing-a-file-content/#findComment-373658 Share on other sites More sharing options...
Ninjakreborn Posted October 20, 2007 Share Posted October 20, 2007 Well if it's dynamic you can auto-generate the .css file (and the code to include it in the page) dynamically from a database. Quote Link to comment https://forums.phpfreaks.com/topic/74020-solved-echoing-a-file-content/#findComment-373661 Share on other sites More sharing options...
shag Posted October 20, 2007 Author Share Posted October 20, 2007 It is not... I simply have a .html file and a .css file. Quote Link to comment https://forums.phpfreaks.com/topic/74020-solved-echoing-a-file-content/#findComment-373664 Share on other sites More sharing options...
Ninjakreborn Posted October 20, 2007 Share Posted October 20, 2007 Then stop wasting time and do what I originally said . Copy the css into a .css file and include it on the page where needed. That's all that is needed. Quote Link to comment https://forums.phpfreaks.com/topic/74020-solved-echoing-a-file-content/#findComment-373665 Share on other sites More sharing options...
ryeman98 Posted October 20, 2007 Share Posted October 20, 2007 You may be new to the forums but when you see THAT many stars, such as businessman's, you just do what they say and it'll almost always work. Quote Link to comment https://forums.phpfreaks.com/topic/74020-solved-echoing-a-file-content/#findComment-373666 Share on other sites More sharing options...
shag Posted October 20, 2007 Author Share Posted October 20, 2007 I understand what you are saying... I have the .css file and can <link media="screen" href="style.css" type="text/css" rel="stylesheet"> But what my question is to how to get the .html in there without going through every single line... Maybe provide an example? Quote Link to comment https://forums.phpfreaks.com/topic/74020-solved-echoing-a-file-content/#findComment-373669 Share on other sites More sharing options...
Cagecrawler Posted October 20, 2007 Share Posted October 20, 2007 If you mean the bit between the body tags, then a straight include should work: <body> <?php if($logged_in) { include("bodycontents.php"); } else { include("login.php"); } ?> </body> Quote Link to comment https://forums.phpfreaks.com/topic/74020-solved-echoing-a-file-content/#findComment-373670 Share on other sites More sharing options...
shag Posted October 20, 2007 Author Share Posted October 20, 2007 Thank you very much cage! Worked great can't believe I missed that... Quote Link to comment https://forums.phpfreaks.com/topic/74020-solved-echoing-a-file-content/#findComment-373673 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.