Jump to content

[SOLVED] PHP template


fm1

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/87193-solved-php-template/
Share on other sites

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();
?>

Link to comment
https://forums.phpfreaks.com/topic/87193-solved-php-template/#findComment-445969
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/87193-solved-php-template/#findComment-446048
Share on other sites

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();
?>

Link to comment
https://forums.phpfreaks.com/topic/87193-solved-php-template/#findComment-446053
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/87193-solved-php-template/#findComment-446059
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/87193-solved-php-template/#findComment-446061
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/87193-solved-php-template/#findComment-446073
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/87193-solved-php-template/#findComment-446080
Share on other sites

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!!

Link to comment
https://forums.phpfreaks.com/topic/87193-solved-php-template/#findComment-446084
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.