1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Create pages code

Discussion in 'PHP & Perl' started by mandude, Aug 20, 2010.

  1. mandude

    mandude Jr. VIP Jr. VIP Premium Member

    Joined:
    Feb 18, 2008
    Messages:
    797
    Likes Received:
    306
    Location:
    Tampa FL
    Hey, I am trying to figure something out. I know its possible, not sure if all of it is though.

    I am creating a website, and the home page will have links on it to different pages. each subpage has a product on it, with pic, description, name. I know you can easily get a template subpage to call <get> function to get the info from a file.

    But how can I go about so I dont have to make a million subpages, is there a way that some code can create the page as it calls it from the home page? For example, home page has a link to productz.php, but productz.php doesnt exist cuz it was never called before. Clicking the link creates a php page, site.com/productz.php and it gets the required info from productz.txt and picture from picz.jpg or etc.

    Is this possible? More so, can someone help me figure out the code?

    Thank you in advance!
     
  2. cyklotrial

    cyklotrial Regular Member

    Joined:
    Oct 13, 2008
    Messages:
    248
    Likes Received:
    82
    Location:
    Wonderland
    You can use .htaccess to change every calls like this one:
    Code:
    http://domain.com/blablabla.php
    to:
    Code:
    http://domain.com/index.php?page=blablabla
    In index.php you have to have code that is checking if GET array value ($_GET['page']) is empty or no.

    If it's empty=>show homepage
    If it have some value like "blablabla" search in folder (for example) "InfoTexts" file "blablabla.txt". If file exist open it and use all info that are in it.
    If no=>404 redirect
    Search in folder "InfoImages" file "blablabla.jpeg". If exist - use it. If no - That's OK xD

    Very simple and easy to implement.
     
  3. cyklotrial

    cyklotrial Regular Member

    Joined:
    Oct 13, 2008
    Messages:
    248
    Likes Received:
    82
    Location:
    Wonderland
    Looks like we both found solution.
    Topic can be closed.