index.php?page=aboutme

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
SpaceshipSpaceship
Watch

thestudent

Account Closed
Impact
1
Hi,
Some people wonder how they can make their pages look like: http://mysite.com/index.php?page=aboutme so here's a tutorial I wrote on it.


Code:
<?PHP

// Sample script written by Daynah
// PHP-Princess.net

// Where all your text files are located at
$directory = 'version2/';

// If the variable exists
// Example: If the url is index.php?page=aboutme
if($page)
{
// Does the file $directory/$page.txt exist?
if(is_file("$directory$page.txt"))
include("$directory$page.txt");
else
print "Sorry, this page does not exist";
}

// If the page is just called as index.php
// Then just include the default main.txt page
else
{
$mypage = 'main.txt';
include("$directory$mypage");
}
?>I also attached a zip file that has all the files in it's proper directory. Unzip it, put it on your domain. Then go to the index.php site. Ex. http://yourdomain.php/phpsample1/index.php

You can go and edit http://yourdomain.php/phpsample1/version2/main.txt or http://yourdomain.php/phpsample1/version2/aboutme.txt if you like.

If you want to add more files so you can call the page like: http://yourdomain.php/phpsample1/ind...page=downloads

Just add another file called downloads.txt to the version2 directory. Test it out and see if it works. If you need more help, please post here.

You can download the files here
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
That only works if REGISTER_GLOBAL is set to on, and thats a security risk ;)

Replace $page with $_GET[page], and it will work :hehe:
 
0
Close
Using $_GET[page] will give you:
Notice: Use of undefined constant page - assumed 'page'.

If you are going to use the full name, put quotes around the key like $_GET['page']
 
0
Close
PHP4 is fine without the "'"s
 
0
Close
JRBHosting said:
PHP4 is fine without the "'"s

It's not about php version, it's about standards. You should always encase array keys in quotes.
 
0
Close
I understand that, I am just saying that it works for me ;)

Yes, it is better to use the 's.
 
0
Close
0
Close
CatchedCatched

We're social

Escrow.com
Spaceship
CryptoExchange.com
Domain Recover

NamePros updates

Quick replies: search, your most used replies, and more on every post
Quick replies are easier to find and use now. The quick reply menu has a search box. Type a few letters to find the reply you want. A...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back