Different title, keyword and description in every page's Print

  • 36

How can I add a different title, keyword and description in every page's <head> of my simple php website dynamically?

I have included file header.php in all of my pages, how can i know in what page the user in?

For example, I have php files register.php, and login.php, and I need different titles, keywords and descriptions.

I do not want use the $_GET method.

Thanks!

Solution

Set variables at the top of each page that will be read by header.php. Then insert the values of the variables in the right places in header.php. Here is an example:

register.php:

<?php
    $title ="Registration";
    $keywords ="Register, login";
    $description ="Page for user registration";

    include('header.php');?>

header.php

<html><head>
        <meta name="keywords" content="<?php echo $keywords;?>" />
        <meta name="description" content="<?php echo $description;?>" />
        <title><?php echo $title;?></title></head><body>

Was this answer helpful?

« Back

Powered by WHMCompleteSolution