Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: In a website that ALL webpages are of index.php?id=1, index.php?id=2, index.php?id=3,

  1. #1
    Join Date
    Oct 2004
    Posts
    425
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default In a website that ALL webpages are of index.php?id=1, index.php?id=2, index.php?id=3,

    In a website that ALL webpages are of index.php?id=1, index.php?id=2, index.php?id=3, index.php?id=4,...... how this mechanism is and work ? are they take markup code from database table fields, by this way ?

  2. #2
    Join Date
    May 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    They are probably using ajax to replace frames or sections of the page without refreshing the entire page.

  3. #3
    Join Date
    Oct 2004
    Posts
    425
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default

    I mean from home: index.php?id=1 you go to a subpage eg: index.php?id=2 by click ...well ? are they save markup code from database table fields, and visitor retrieves this by surf this way ? If yes, how the developer edits the markup code from database fields, in a WYSIWYG Editor ?

  4. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Thats using PHP $_GET, here:
    Code:
    <?php
    if(isset($_GET['greeting']) && $_GET['greeting'] == "hi"){
      echo "Hello Mr!";
    }
    ?>
    Then go to: ?greeting=hi
    Jeremy | jfein.net

  5. #5
    Join Date
    Oct 2004
    Posts
    425
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default

    I know this I wanted to learn if: involves Database? how appear the field(markup code)?is it encoded this TEXT Database data ? How edit code database TEXT fields, in a WYSIWYG Editor ?

  6. #6
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,634
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    it can involve a database, but it isn't necessary. If it is fairly static content (meaning not something like a blog or something else you need a DB for), it would be easier to code like this (using php):

    PHP Code:
    <php
    if (!isset ($_GET['id'])){ //if no GET data present, load the default page content
       
    include "path/to/default/content.php";
    } else { 
    //otherwise, use the GET 'id' to load the desired content
       
    $page $_GET['id'];
       include 
    "path/to/content/page".$page.".php"//e.g., if the url is "index.php?id=1"
          //this will load the content from your external file named "page1.php" into index.php.
    }
    ?> 
    Last edited by traq; 05-28-2009 at 04:13 AM.

  7. #7
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Well, first of all, its <?php not <php. Second there is a huge security whole with that script and that is that if an htaccess file is protecting something, it can bypass that protection.
    Jeremy | jfein.net

  8. #8
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,634
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    Sorry about the typo!

    Could the hole be fixed by matching the GET info to a predefined list? Something like this:
    PHP Code:
    <?php
    if (!isset ($_GET['id'])){ //if no GET data present, load the default page content
       
    include "path/to/default/content.php";
    } else { 
    //otherwise, use the GET 'id' to load the desired content
       
    $GETpage $_GET['id']; //variable to store GET page id
       
    $OKpages = array ('page1''page2''page3'); //list of valid options
       
    $page null//make sure nothing is selected by default
       
    foreach ($OKpages as $OK) { //loop over OKpages array
          
    if ($GETpage == $OK){  //if one matches the GET page id,
             
    $page $GETpage;  //use that as the page to load
             
    include "path/to/content/".$page.".php"//e.g., if the url is "index.php?id=page1"
                //this will load the content from your external file named "page1.php" into index.php.
             
    break;  //and stop comparing
          
    } else {  //if there's no match,
             
    echo 'You Are Lost!';  //they're trying to visit a restricted or non-existent page
             
    include "path/to/sitemap";  //tell them where they *can* go
          
    }
       }
    }
    ?>
    Edit: Tested code and made corrections as to line order; also corrected <php typo that I accidentally copied from my post above
    Last edited by traq; 05-30-2009 at 03:38 AM.

  9. #9
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Instead of the foreach, you should use in_array(). Something like the following should work:

    Code:
    <php
    if (!isset ($_GET['id'])){ //if no GET data present, load the default page content
       include "path/to/default/content.php";
    } 
    else { //otherwise, use the GET 'id' to load the desired content
      $pages = array ('page1', 'page2', 'page3'); //list of valid options
      if (in_array($_GET['page'], $pages)) {
       include('/path/to/'.$_GET['page']);
      } 
      else {  //if there's no match,
       echo 'You Are Lost!';  //they're trying to visit a restricted or non-existent page
       include "path/to/sitemap";  //tell them where they *can* go
      }
     }
    }
    ?>
    Not tested and this really does depend on the way you have everything set up, but should work nontheless.

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  10. #10
    Join Date
    Oct 2004
    Posts
    425
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default

    is it encoded this TEXT Database data ? I MEAN SPECIAL CHARACTERS[FOR DB] APPEAR AS IS HENCE WE HAVE "text" db field type ?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •