+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: php?id=something

  1. #1
    Nate_Benton's Avatar
    Nate_Benton is offline x10 Lieutenant Nate_Benton is an unknown quantity at this point
    Join Date
    Aug 2005
    Location
    Plainwell, Michigan, USA.
    Posts
    285

    php?id=something

    I'm creating a site and want to use this "effect" where its the same php page, but its like different sites, with id's though.
    I'm dumb with php, so if anybody can run down how to do this, I'd greatly appreciate it.

  2. #2
    celebraces is offline Banned celebraces is an unknown quantity at this point
    Join Date
    May 2006
    Posts
    6

    Re: php?id=something

    Code:
    <?php
    include($_GET['id'].".php");
    ?>
    Save your files as *.php and save them in the same folder as the script. Link to the individual pages as <a href="index.php?id=home"> etc.

  3. #3
    Nate_Benton's Avatar
    Nate_Benton is offline x10 Lieutenant Nate_Benton is an unknown quantity at this point
    Join Date
    Aug 2005
    Location
    Plainwell, Michigan, USA.
    Posts
    285

    Re: php?id=something

    Wow, thank you.
    This was exactly what I was looking for

  4. #4
    Tomballa is offline x10Hosting Member Tomballa is an unknown quantity at this point
    Join Date
    Jun 2006
    Posts
    15

    Re: php?id=something

    Quote Originally Posted by celebraces
    Code:
    <?php
    include($_GET['id'].".php");
    ?>
    Save your files as *.php and save them in the same folder as the script. Link to the individual pages as <a href="index.php?id=home"> etc.
    Correct me if I am wrong, but can't someone load a remote php page and destroy your site using that?

  5. #5
    dharmil's Avatar
    dharmil is offline x10 Elder dharmil is an unknown quantity at this point
    Join Date
    Sep 2005
    Location
    Avenel New Jersey
    Posts
    828

    Re: php?id=something

    PHP Code:
    <?php
    $page 
    $_GET['id'];
    if (
    file_exists("public_html/$page.php")) {
    include(
    "$page.php");
    } else { echo 
    "file not found"; }
    ?>
    would that help prevent people from messing up your site?
    Last edited by dharmil; 07-26-2006 at 03:57 PM.

  6. #6
    The_Magistrate's Avatar
    The_Magistrate is offline x10 Elder The_Magistrate is an unknown quantity at this point
    Join Date
    May 2005
    Location
    PA
    Posts
    559

    Re: php?id=something

    Instead of using .php?id=something, look into permalinks and mod_rewrite. X10 supports rewrite rules, and they can help the security of your site and look a helluva lot nicer than ?id=...

    Instead of yourdomain.com/index.php?id=something&a=b you would have yourdomain.com/something/b/ or similar.
    Getting Started | Terms of Service | Paid Hosting | Forum Rules | Free Server Status | Banned Countries

    If I have helped you through one of my posts, please click the
    blue checkbox on the right below my avatar to add to my reputation.

  7. #7
    dharmil's Avatar
    dharmil is offline x10 Elder dharmil is an unknown quantity at this point
    Join Date
    Sep 2005
    Location
    Avenel New Jersey
    Posts
    828

    Re: php?id=something

    Quote Originally Posted by The_Magistrate
    Instead of using .php?id=something, look into permalinks and mod_rewrite. X10 supports rewrite rules, and they can help the security of your site and look a helluva lot nicer than ?id=...

    Instead of yourdomain.com/index.php?id=something&a=b you would have yourdomain.com/something/b/ or similar.
    is this how you would do it?
    in htaccess file
    RewriteRule index/(.*)$/(.*)$ /index.php?id=$1&a=$2

  8. #8
    [XiRE] is offline x10Hosting Member [XiRE] is an unknown quantity at this point
    Join Date
    Jul 2006
    Location
    Detroit Michigan
    Posts
    44

    Re: php?id=something

    Quote Originally Posted by Nate_Benton
    I'm creating a site and want to use this "effect" where its the same php page, but its like different sites, with id's though.
    I'm dumb with php, so if anybody can run down how to do this, I'd greatly appreciate it.
    i wrote about a solution for this after seeing your thread in my PHP includes tutorial.

  9. #9
    Tomballa is offline x10Hosting Member Tomballa is an unknown quantity at this point
    Join Date
    Jun 2006
    Posts
    15

    Re: php?id=something

    PHP Code:
    <?php
    function index()
    {
    include (
    "home.php");
    }

    $choice=$_GET['id'];

    switch(
    $choice)
    {
    case 
    "faq":
    include (
    "faq.php"); 
    break;

    case 
    "tutorials":
    include (
    "tuts.php"); 
    break;

    default:
    index();
    }
    ?>
    In the script above, if someone where to go to index.php, it would show the home.php file. If someone where to go to index.php?id=faq, faq.php would load but the url would still look like index.php?id=faq

    This is just an example of what you can use to fit your needs. You don't have to use includes for this to work. I just did b/c that is the simplest way.
    Last edited by Tomballa; 07-28-2006 at 03:20 PM.

  10. #10
    lambada's Avatar
    lambada is offline x10 Elder lambada is an unknown quantity at this point
    Join Date
    Mar 2006
    Location
    Caister, Gt Yarmouth, Norfolk, ENGLAND
    Posts
    1,222

    Re: php?id=something

    Quote Originally Posted by Tomballa
    PHP Code:
    <?php
    function index()
    {
    include (
    "home.php")
    }

    $choice=$_GET['id'];

    switch(
    $choice)
    {
    case 
    "faq":
    include (
    "faq.php"); 
    break;

    case 
    "tutorials":
    include (
    "tuts.php"); 
    break;

    default:
    index();
    }
    ?>
    In the script above, if someone where to go to index.php, it would show the home.php file. If someone where to go to index.php?id=faq, faq.php would load but the url would still look like index.php?id=faq

    This is just an example of what you can use to fit your needs. You don't have to use includes for this to work. I just did b/c that is the simplest way.
    That way isn't the simplest, but it is definately a secure way ;). The quickest was the first idea posted in this thread - but it was highly insecure.
    Lambada - the former Account Manager (before I resigned)




+ Reply to Thread
Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers