[advanced search]
Results from the most recent live auction are here.
11 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read

System Maintenance: NamePros will be offline for 20 minutes at the top of the hour (4AM EST)

Go Back   NamePros.Com > Design and Development > Programming > CODE
User Name
Password

Old 01-25-2007, 08:08 PM   · #1
thestudent
NamePros Regular
 
thestudent's Avatar
 
Name: nujaim
Location: pakistan
Trader Rating: (4)
Join Date: Aug 2005
Posts: 303
NP$: 219.95 (Donate)
thestudent is an unknown quantity at this point
index.php?page=aboutme

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


Please register or log-in into NamePros to hide ads
thestudent is offline   Reply With Quote
Old 01-27-2007, 03:29 PM   · #2
RegisterRants
DNOA Member
 
RegisterRants's Avatar
 
Name: Jason
Trader Rating: (11)
Join Date: Oct 2006
Posts: 1,143
NP$: 257.37 (Donate)
RegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura about
That only works if REGISTER_GLOBAL is set to on, and thats a security risk

Replace $page with $_GET[page], and it will work
__________________
Web Development
RegisterRants is offline  
  Reply With Quote
Old 01-27-2007, 03:32 PM   · #3
Dan
Buy my domains.
 
Dan's Avatar
 
Name: Dan
Trader Rating: (63)
Join Date: Feb 2006
Posts: 2,801
NP$: 54.00 (Donate)
Dan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant futureDan has a brilliant future
Autism Autism Autism Autism Autism Autism Autism
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']
Dan is offline   Reply With Quote
Old 01-27-2007, 03:40 PM   · #4
RegisterRants
DNOA Member
 
RegisterRants's Avatar
 
Name: Jason
Trader Rating: (11)
Join Date: Oct 2006
Posts: 1,143
NP$: 257.37 (Donate)
RegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura about
PHP4 is fine without the "'"s
__________________
Web Development
RegisterRants is offline  
  Reply With Quote
Old 01-27-2007, 03:45 PM   · #5
Matthew.
Stud Sausage
 
Location: England
Trader Rating: (25)
Join Date: Dec 2006
Posts: 1,545
NP$: 32.41 (Donate)
Matthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud of
Adoption Breast Cancer Breast Cancer Cancer Survivorship
Originally Posted by JRBHosting
PHP4 is fine without the "'"s



It's not about php version, it's about standards. You should always encase array keys in quotes.
__________________
My NamePros Tools
(firefox plugin, google gadget etc)
Matthew. is offline   Reply With Quote
Old 01-27-2007, 03:49 PM   · #6
RegisterRants
DNOA Member
 
RegisterRants's Avatar
 
Name: Jason
Trader Rating: (11)
Join Date: Oct 2006
Posts: 1,143
NP$: 257.37 (Donate)
RegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura aboutRegisterRants has a spectacular aura about
I understand that, I am just saying that it works for me

Yes, it is better to use the 's.
__________________
Web Development
RegisterRants is offline  
  Reply With Quote
Old 01-27-2007, 03:52 PM   · #7
Matthew.
Stud Sausage
 
Location: England
Trader Rating: (25)
Join Date: Dec 2006
Posts: 1,545
NP$: 32.41 (Donate)
Matthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud ofMatthew. has much to be proud of
Adoption Breast Cancer Breast Cancer Cancer Survivorship
Originally Posted by JRBHosting
I understand that, I am just saying that it works for me

Yes, it is better to use the 's.



It probably works for you because your error reporting level is lower. Try adding
PHP Code:
error_reporting(E_ALL);
to the top of your script (not that you would want/need to, but just saying as an example)

Info:
http://uk.php.net/manual/en/languag...s.array.foo-bar
__________________
My NamePros Tools
(firefox plugin, google gadget etc)
Matthew. is offline   Reply With Quote
Closed Thread

NamePros is a revenue sharing forum.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


Site Sponsors
http://www.mobisitetrader.com/ Grow your forum! Find out how!
Advertise your business at NamePros
All times are GMT -7. The time now is 12:13 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0