Current location: Hot Scripts Forums » Programming Languages » PHP » making urls like index.php?page=home


making urls like index.php?page=home

Reply
  #1 (permalink)  
Old 06-22-04, 11:43 PM
rottedham rottedham is offline
Newbie Coder
 
Join Date: May 2004
Location: Katy, TX
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
making urls like index.php?page=home

hi.. i've asked questions similar to this before but never really got the answer i was looking for. how do i make urls for my links something like index.php?page=home ...i still don't fully understand how to do this.. i don't need it to use MySQL, just php. thanks in advance.
Reply With Quote
  #2 (permalink)  
Old 06-23-04, 01:19 AM
MasQ's Avatar
MasQ MasQ is offline
Newbie Coder
 
Join Date: Feb 2004
Location: Norway/Oslo
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Something like this:

PHP Code:

<? 

if (isset($page)){ 
if (@
fopen("$page.php""r")){ 
include (
"$page.php"); 

else { 
include (
"404.php"); 


else { 
include (
"main.php"); 

?>
Remeber to make your own 404.php
__________________
**Schmmotch**
Reply With Quote
  #3 (permalink)  
Old 06-23-04, 01:30 AM
rottedham rottedham is offline
Newbie Coder
 
Join Date: May 2004
Location: Katy, TX
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
thanks for the reply! will this work with all the other pages like links, downloads, etc.?
Reply With Quote
  #4 (permalink)  
Old 06-23-04, 01:41 AM
rottedham rottedham is offline
Newbie Coder
 
Join Date: May 2004
Location: Katy, TX
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
i also have another question.. how would i set up the links to work with this code?
Reply With Quote
  #5 (permalink)  
Old 06-23-04, 02:07 AM
MasQ's Avatar
MasQ MasQ is offline
Newbie Coder
 
Join Date: Feb 2004
Location: Norway/Oslo
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
If you use the code in you index.php it should work with all you pages in the root (same as index.php) directory...

I would recomend you using you imagination with this piece of code...

Im going to use the code with my <IFRAME> like this:

Code:
<iframe width="704" height="100%" src="
PHP Code:

<?php

if (isset($page)){ 
if (@
fopen("$page.php""r")){ 
echo (
"$page.php"); 

else { 
echo (
"404.php"); 


else { 
echo (
"news.php"); 

?>
Code:
" name="main" frameborder="0"></iframe>
When I first found the code I didn't use it for a long time, but now that its modyfied to fit my IFRAME, its works nicly...
__________________
**Schmmotch**
Reply With Quote
  #6 (permalink)  
Old 06-23-04, 02:49 AM
MasQ's Avatar
MasQ MasQ is offline
Newbie Coder
 
Join Date: Feb 2004
Location: Norway/Oslo
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
BTW!!

you may have to use:

PHP Code:

$page $_GET['page']; 

at the beginning of the script...
__________________
**Schmmotch**
Reply With Quote
  #7 (permalink)  
Old 06-23-04, 08:47 AM
Klesti Klesti is offline
Newbie Coder
 
Join Date: May 2004
Location: Albania
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
You place files like : about.php, scores.php, pictures.php in the root folder and instead of placing a link like

http://www.domain.com/about.php

place a link in thhis way:

http://www.domain.com/index.php?page=about

Last edited by Klesti; 06-23-04 at 08:49 AM.
Reply With Quote
  #8 (permalink)  
Old 07-02-04, 08:13 PM
Andy1984's Avatar
Andy1984 Andy1984 is offline
Newbie Coder
 
Join Date: Jul 2004
Posts: 89
Thanks: 0
Thanked 0 Times in 0 Posts
heres a snippet from a news publishing app i was making
PHP Code:

<?PHP


function test($id){
echo 
"$id";
}

function 
test2(){
echo 
"blah blah blah";
}

switch(
$_GET['action']) {
    case 
'test':
//url looks like page.php?action=test&id=get_whats_after_id
        
test($_GET['id']);
        break;

case 
'test2':
//url looks like page.php?action=test2
test2();
break;
}
?>
this may not be the best way todo this but it works, oh btw i get error if i just goto page.php dunno how to fix it yet, only been learning for about 2 weeks

hope it helps you
Reply With Quote
  #9 (permalink)  
Old 07-03-04, 06:50 PM
kardon kardon is offline
Newbie Coder
 
Join Date: Jun 2004
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
You can also let it grab a file. I never set it up on my site and I can type ..com/boy&file=index and it works for me so I think It should work for you.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
making dynamic URLs? rottedham PHP 1 05-16-04 01:37 PM
List of urls with ASP Naz ASP 8 02-12-04 02:28 PM
Please help me with my problem of MP3 and php know script for making mp3 portal??? Extremaltours Script Requests 3 01-30-04 07:59 AM
Help making a script. Arctic ASP 0 10-02-03 06:50 PM
dynamic url's in xhtml pages? tom HTML/XHTML/XML 4 09-26-03 05:11 PM


All times are GMT -5. The time now is 05:05 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.