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 ?
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 ?
They are probably using ajax to replace frames or sections of the page without refreshing the entire page.
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 ?
Thats using PHP $_GET, here:
Then go to: ?greeting=hiCode:<?php if(isset($_GET['greeting']) && $_GET['greeting'] == "hi"){ echo "Hello Mr!"; } ?>
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 ?
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.
Adrian ~ facebook | gist/github
['66.215.156.37','208.75.149.97'] // ip,ip array!
"Take that sticker *off* your hat; you look stupid" --Wil Wheaton
Well, first of all, its<?phpnot<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.
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.
Adrian ~ facebook | gist/github
['66.215.156.37','208.75.149.97'] // ip,ip array!
"Take that sticker *off* your hat; you look stupid" --Wil Wheaton
Instead of the foreach, you should use in_array(). Something like the following should work:
Not tested and this really does depend on the way you have everything set up, but should work nontheless.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 } } } ?>
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
is it encoded this TEXT Database data ? I MEAN SPECIAL CHARACTERS[FOR DB] APPEAR AS IS HENCE WE HAVE "text" db field type ?
Bookmarks