Jump to content

[SOLVED] welcome message in title bar


ilikephp

Recommended Posts

put it in a file (include.php) like this:

<?php
$siteTitle = 'Welcome to my website';
?>

 

then have all your pages formatted like this:

<?php
include 'include.php';
?><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?=$siteTitle;?></title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<!-- HTML HERE -->
</body>
</html>

As long as your files are php files then you can simply add

 

require("title.php");

 

to each page where you would normally put the title. The file title.php would consist of

 

<title>The title of your website</title>

 

You can then alter the title on every page by altering the title.php file

Thanks !! it works..

but I have a very small problem:

 

when I put:

<?php

include "/www/arabic/include.php";

?>

 

everything is OK coz www is the folder of the server in my windowx XP

 

What can I put if I need to upload it on the server(online)

coz there is no www

instead I would use relative linking instead.

 

so use ../ to move up one directory.

 

if your tree looks like so:

/root
     /folder1
          /file1.php
          /file2.php
     /folder2
          /file1.php
     /folder3

and your in folder2/file1.php, and you want to go to folder1/file2.php, you would do this:

 

<?php include('../folder1/file2.php');?>

 

doing it this way, will allow the site to work on any server at any depth.

        /root

              /arabic

                    /include.php

 

              /SubPage

                    /Fathers

                        /index.php

 

 

inside include: I have the script for the  title

inside index: I am puting this:

<?php

include ('../arabic/include.php');

?>

 

I wouldn't place it in the same folder, because what will happen if you try to access it from another file outside that folder? You may run into the problem again.

 

I would make in "incl" folder in the root folder. This will hold all the included files (functions.php, db.php, globalVariables.php)

 

so it would look like this:

/root
     /incl
          /functions.php
          /db.php
          /globalVariabls.php
     /arabic
          /SubPage
               /Fathers
                    /index.php

 

Then you will want to add a file in the /incl folder called "includes.php", so now your directory structure would look like this:

 

/root
     /incl
          /functions.php
          /db.php
          /globalVariabls.php
          /includes.php
     /arabic
          /SubPage
               /Fathers
                    /index.php

 

In the file "includes.php" you would place this:

 

<?php
include 'functions.php';
include 'db.php';
include 'globalVariabls.php';
?>

 

In the file index.php (your current file), you would have this:

 

<?php
include '../../../incl/includes.php';
?><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?=$siteTitle;?></title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<!-- HTML HERE -->
</body>
</html>

 

Now, this file contains everything that is in the incl folder.

in the file include.php I have this:

 

<?php

$siteTitle = 'Welcome to my website';

?>

 

 

should I remove it and put:

<?php

include 'functions.php';

include 'db.php';

include 'globalVariabls.php';

?>

 

 

 

 

        and in this function:include '../../../incl/includes.php';

why I have .. (3 times)? before the folder incl I have the root only?

 

for every "../" it moves up a directory.

 

This is so you don't have to list all your include files in every file, just a link to this file, which will add all the files you need to the running file, it makes for less typing (the files must exist though).

<?php
include 'functions.php';
include 'db.php';
include 'globalVariabls.php';
?>

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.