snug's Profile User Rating: -----

Reputation: 0 Apprentice
Group:
New Members
Active Posts:
1 (0 per day)
Joined:
06-July 13
Profile Views:
305
Last Active:
User is offline Jul 16 2013 05:13 PM
Currently:
Offline

Previous Fields

Dream Kudos:
0
Icon   snug has not set their status

Posts I've Made

  1. In Topic: Creating a simple dynamic website with PHP

    Posted 6 Jul 2013

    View Postmnkhalid, on 01 July 2013 - 02:32 AM, said:

    View PostRudiVisser, on 06 September 2011 - 05:10 AM, said:

    View Postskorned, on 04 September 2011 - 10:24 PM, said:

    Nice tutorial, and like you noted, the first one to really go in-depth and deal with all scenarios and potential pitfalls. Just one little typo I think I found...
    Shouldn't it read (note the exclamation point): ..? As in, shouldn't the action be set to index only if the file does not exist?

    Great - Updated it, thanks for that!

    I had a test page going whilst typing this up, but updated each snippet rather than copy/paste so it must've got out of sync :nottalkingtoyou:/>/>

    Thanks!


    How Do i dynamically update the title of my page ?



    I was just trying to do the same thing, here is what I came up with.

    <!DOCTYPE html>
      <?php
        //set default name
        $action = 'index';
        //specify disallow paths
        $disallow_paths = array('header', 'footer');
        if (!empty($_GET['action'])){
          $tmp_action = basename($_GET['action']);
        //if it's not a diallowed path, and if the file exists, make $action
          if (!in_array($tmp_action, $disallow_paths) && file_exists("templates/{$tmp_action}.htm"))
            $action = $tmp_action;
        }
        echo "<html>
          <head>
            <link type='text/css' rel='stylesheet' href='stylesheet.css' />
            <title>Title - " . $action . "</title>
          </head>
          <body>";
            include("templates/header.htm");
            include("templates/$action.htm");
            include("templates/footer.htm");
          echo "</body>
            </html>";
    
    


    Not sure if this is the best way to do it, but it's working for me so far. Basically if I went to domain.com/?action=test, my title would be:

    Title - test

My Information

Member Title:
New D.I.C Head
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:

Contact Information

E-mail:
Private

Friends

snug hasn't added any friends yet.

Comments

snug has no profile comments yet. Why not say hello?