fm1 Posted January 22, 2008 Share Posted January 22, 2008 Hi guys,im trying to create a php template. heres what i done 3 pages page 1 : home.php <html> <head> <title>My Title</title> <style type="text/css"> body{ background-color: black; color: white; } </style> </head> <body> <h1>Page Title</h1> <p>Page content goes here...</p> <p>Copyright 2007 Company Name</p> </html> page opens in browser but has no links to any other pages like my about .php page then page 2: functions.php <?php function display_header($title){ ?> <html> <head> <title><?php echo $title; ?></title> <style type="text/css"> body{ background-color: black; color: white; } <style> </head> <body> <h1><?php echo $title; ?></h1> <?php } function display_footer(){ ?> <p>Copyright 2007 Company Name</p> </html> <?php } ?> nothing just blank white comes out in the browser, dont know why then page 3: about.php <?php include('functions.php'); display_header('About Company Name'); ?> <p>This is the content for the about page...</p> <?php display_footer(); ?> function display_footer(){ ?> <p>Copyright <?php echo date('Y'); ?> Company Name</p> <html> <?php } ?> Parse error: syntax error, unexpected '}' in C:\xampp\htdocs\test3\about.php on line 14 please help, or is there any other easier way to create a std php web template Quote Link to comment https://forums.phpfreaks.com/topic/87193-solved-php-template/ Share on other sites More sharing options...
themistral Posted January 22, 2008 Share Posted January 22, 2008 Change then page 3: about.php <?php include('functions.php'); display_header('About Company Name'); ?> <p>This is the content for the about page...</p> <?php display_footer(); ?> function display_footer(){ ?> <p>Copyright <?php echo date('Y'); ?> Company Name</p> <html> <?php } ?> to then page 3: about.php <?php include('functions.php'); display_header('About Company Name'); ?> <p>This is the content for the about page...</p> <?php display_footer(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/87193-solved-php-template/#findComment-445969 Share on other sites More sharing options...
fm1 Posted January 22, 2008 Author Share Posted January 22, 2008 Change then page 3: about.php <?php include('functions.php'); display_header('About Company Name'); ?> <p>This is the content for the about page...</p> <?php display_footer(); ?> function display_footer(){ ?> <p>Copyright <?php echo date('Y'); ?> Company Name</p> <html> <?php } ?> to then page 3: about.php <?php include('functions.php'); display_header('About Company Name'); ?> <p>This is the content for the about page...</p> <?php display_footer(); ?> about.php now comes up with a black screen in browser, no text functions.php is still white in browser. and home.php has text but no links to the other pages Quote Link to comment https://forums.phpfreaks.com/topic/87193-solved-php-template/#findComment-446048 Share on other sites More sharing options...
themistral Posted January 22, 2008 Share Posted January 22, 2008 OK - gone a bit deeper... Use this as your functions file <?php function display_header($title){ $text .= '<html>'; $text .= '<head>'; $text .= '<title>'.$title.'</title>'; $text .= '<style type="text/css">'; $text .= 'body{ background-color: black; color: white; }'; $text .= '</style>'; $text .= '</head>'; $text .= '<body>'; $text .= '<h1>'.$title.'</h1>'; return $text; } function display_footer(){ $text .= 'Copyright 2007 Company Name</p>'; $text .= '</html>'; return $text; } ?> then this is your about us page <?php echo display_header('About Company Name'); ?> <p>This is the content for the about page...</p> <?php echo display_footer(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/87193-solved-php-template/#findComment-446053 Share on other sites More sharing options...
fm1 Posted January 22, 2008 Author Share Posted January 22, 2008 OK - gone a bit deeper... Use this as your functions file <?php function display_header($title){ $text .= '<html>'; $text .= '<head>'; $text .= '<title>'.$title.'</title>'; $text .= '<style type="text/css">'; $text .= 'body{ background-color: black; color: white; }'; $text .= '</style>'; $text .= '</head>'; $text .= '<body>'; $text .= '<h1>'.$title.'</h1>'; return $text; } function display_footer(){ $text .= 'Copyright 2007 Company Name</p>'; $text .= '</html>'; return $text; } ?> then this is your about us page <?php echo display_header('About Company Name'); ?> <p>This is the content for the about page...</p> <?php echo display_footer(); ?> functions.php still blank about.php Fatal error: Call to undefined function display_header() in C:\xampp\htdocs\test3\about.php on line 2 dont you think theres an error maybe in my home.php file. please note, i only have 3 scripts home.php about.php functions.php heres my home.php <html> <head> <title>My Title</title> <style type="text/css"> body{ background-color: black; color: white; } </style> </head> <body> <h1>Page Title</h1> <p>Page content goes here...</p> <p>Copyright 2007 Company Name</p> </html> the other 2scripts are changed to the ones you gave me now Quote Link to comment https://forums.phpfreaks.com/topic/87193-solved-php-template/#findComment-446059 Share on other sites More sharing options...
themistral Posted January 22, 2008 Share Posted January 22, 2008 Sorry - didn't include the functions file in the about.php Change <?php echo display_header('About Company Name'); ?> <p>This is the content for the about page...</p> <?php echo display_footer(); ?> to <?php include('functions.php'); echo display_header('About Company Name'); ?> <p>This is the content for the about page...</p> <?php echo display_footer(); ?> Before worrying about the other page, let me know if this makes the about us page work - let's do one thing at a time! functions.php will show a blank page - it is just a list of functions that are available to be used within your pages. Quote Link to comment https://forums.phpfreaks.com/topic/87193-solved-php-template/#findComment-446061 Share on other sites More sharing options...
fm1 Posted January 22, 2008 Author Share Posted January 22, 2008 thanks, both home.php and about.php are working how do i add a link to home.php to link about.php to home. so that when I open home.php then there a link to about.php Quote Link to comment https://forums.phpfreaks.com/topic/87193-solved-php-template/#findComment-446071 Share on other sites More sharing options...
fm1 Posted January 22, 2008 Author Share Posted January 22, 2008 Sorry - didn't include the functions file in the about.php Change <?php echo display_header('About Company Name'); ?> <p>This is the content for the about page...</p> <?php echo display_footer(); ?> to <?php include('functions.php'); echo display_header('About Company Name'); ?> <p>This is the content for the about page...</p> <?php echo display_footer(); ?> Before worrying about the other page, let me know if this makes the about us page work - let's do one thing at a time! functions.php will show a blank page - it is just a list of functions that are available to be used within your pages. Quote Link to comment https://forums.phpfreaks.com/topic/87193-solved-php-template/#findComment-446073 Share on other sites More sharing options...
themistral Posted January 22, 2008 Share Posted January 22, 2008 Find <p>Page content goes here...</p> in your home page and change to <a href="about.php" target="_self">About</a> <p>Page content goes here...</p> This will give you a simple text link. Quote Link to comment https://forums.phpfreaks.com/topic/87193-solved-php-template/#findComment-446076 Share on other sites More sharing options...
fm1 Posted January 22, 2008 Author Share Posted January 22, 2008 Find <p>Page content goes here...</p> in your home page and change to <a href="about.php" target="_self">About</a> <p>Page content goes here...</p> This will give you a simple text link. thanks well I guese im sorted now thanks to you.are you perhaps on msn messenger,gmail or skype, how much years exp you got, i got about only +4months exp,need to learn more Quote Link to comment https://forums.phpfreaks.com/topic/87193-solved-php-template/#findComment-446080 Share on other sites More sharing options...
themistral Posted January 22, 2008 Share Posted January 22, 2008 I started out 7 years ago with notepad and online tutorials. I have learnt a lot from visiting various forums as well, that's why I like to help others where I can. I would suggest finding some tutorials online and take it from there. There are always people on this forum willing to help - and people who are available to help will do so straight away. I am not always available, so the forum is your best bet - but feel free to pm me! Don't forget to mark the thread as solved if your problem is sorted now!! Quote Link to comment https://forums.phpfreaks.com/topic/87193-solved-php-template/#findComment-446084 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.