Meta Tags And Title Tag In PHP Include Files

Discussion in 'Programming' started by mike810, Jan 7, 2010.

  1. #1
    Hello everyone, hopefully someone here can help me with my problem.

    I own some sites which run on php includes. The main one has about 500 pages being included through one file, watch.php

    http://www.simpsonsepisodes.com/viewer/watch.php?jump=408

    Watch.php is the template and it pulls the page 408 to be displayed in it.

    I want all the include pages to have their own meta tags and title tag which will be seen by the search engines and make my site search much more efficient and easy.

    I have tried several methods but my php skills are not the best. Does anyone have any solutions?
     
    mike810, Jan 7, 2010 IP
  2. Mail Propeller

    Mail Propeller Peon

    Messages:
    44
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi mike810,

    It looks like your problem is that your include files are included after your metatags are written.


    What I think you will end up having to do, is break apart the content within that include and put it into variables.

    $metadata = '<meta name="description" content="Love the simpsons? Dont know where to watch it? Look no futher www.simpsonsepisodes.com is here for you." />
    <meta name="keywords" content="Watch The Simpsons Online, watch simpsons free, homer streaming, lisa simpson, stream the simpsons free, where to watch the simpsons, the simpsons cinemas, simpsons, high quality, barting over" />
    ';
    $contents = <original contents of the include>;

    And you will have to include(408.php); at the top of your file instead of in the middle. Then in your view.php where you spit out your meta data, replace it with <?php echo $metadata;?> and where you used to include($_REQUEST["jump"] . ".php"); you will have to replace it with echo $contents;

    It will be a tedious process to set metadata for 500 pages.
     
    Mail Propeller, Jan 7, 2010 IP
  3. Kalyse

    Kalyse Peon

    Messages:
    1,221
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #3
    As a security help, you also need to validate what the user is entering. It looks like your site is vulnerable in your current implementation.
     
    Kalyse, Jan 8, 2010 IP