Jump to content


Photo

A Http://domain.com/index.php?page=blabla


  • Please log in to reply
25 replies to this topic

#1 Once

Once

    Young Padawan

  • Members
  • Pip
  • 16 posts

Posted 05 May 2005 - 02:59 AM

Example-http://overthehills.com/index.php?id=123info
or http://overthehills.com/?id=123info



I need the source to place on my website and what to do in order to use it properly.
I searched the forums/database but everytime I tried it the source kept showing errors. :D

#2 Once

Once

    Young Padawan

  • Members
  • Pip
  • 16 posts

Posted 05 May 2005 - 03:19 AM

If you could THOROUGHLY explain it......it would be VERY helpfull.
I am a php NUBBEEEEEEE/NEWBIEEEEE

#3 Hoot

Hoot

    * Hooty Tooty Fruit *

  • Members
  • PipPipPipPip
  • 1,346 posts
  • Gender:Male
  • Location:Canada
  • Interests:Making Websites, Working in 3D, Playing the Drums

Posted 05 May 2005 - 08:41 AM

it is actuly a very simple PHP script (well I think it is) ok here is the script (and in this it will only show you how to do ?whatever=whatever not how to do ?whatever=whatever&something=something):



<?php
if( !$id )
{
echo"the main text if you goto index.php or what ever your page is called";
}
else if( $id == 123info )
{
echo"the text that is on ?id=123info";
}
?>

there you go, and hope it helps you.

smardy

#4 Once

Once

    Young Padawan

  • Members
  • Pip
  • 16 posts

Posted 05 May 2005 - 12:00 PM

so this is the coding I put on my page?
it looks very diferent than the others.......do I need to change anything?
(we are talking about the coding that I only need to make on page and all other .php files load up in a content box when I choose them, right)?

#5 Hoot

Hoot

    * Hooty Tooty Fruit *

  • Members
  • PipPipPipPip
  • 1,346 posts
  • Gender:Male
  • Location:Canada
  • Interests:Making Websites, Working in 3D, Playing the Drums

Posted 05 May 2005 - 04:24 PM

you can change the echo the variables (mind you it will change when you type the url) and add more in the echo you can also put html if you want to do it that way!

#6 adam123

adam123

    Retired P2L Staff

  • Members
  • PipPipPipPip
  • 2,306 posts
  • Location:London, UK
  • Interests:Programming and stuff.

Posted 05 May 2005 - 04:34 PM

This one should allow you to include pages rather than have all of your content in if statements:

<?php

if (file_exists($_GET['id'] . ".php"))
{
 include $_GET['page'] . ".php";
}
else
{
 include "404.php";
}

?>

Just put that where you want your content to appear and then create any pages you want. For instance, if you had a page called hello.php, you could access it by going to index.php?id=hello. And if you want to include a page in a directory above the current one, use index.php?id=/directory/pagename.

#7 dEcade

dEcade

    P2L Staff

  • P2L Staff
  • PipPipPipPip
  • 1,850 posts
  • Gender:Male
  • Location:Saskatoon, Saskatchewan
  • Interests:Guitar, Programming, Storm Chasing, Games (Designing and playing), Hockey, Photography

Posted 05 May 2005 - 05:37 PM

The code that smardy gave you work the same and it is much easier to write and remember how to write.

dEcade

#8 Once

Once

    Young Padawan

  • Members
  • Pip
  • 16 posts

Posted 05 May 2005 - 06:24 PM

ill try the last one

#9 Once

Once

    Young Padawan

  • Members
  • Pip
  • 16 posts

Posted 05 May 2005 - 06:37 PM

this is what i got-once.c-f-h.com/index.php?id=hello

Warning: main(.php) [function.main]: failed to open stream: No such file or directory in /home/oncecfh/public_html/index.php on line 12

Warning: main() [function.include]: Failed opening '.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/oncecfh/public_html/index.php on line 12

#10 Dark

Dark

    Young Padawan

  • Members
  • Pip
  • 68 posts

Posted 06 May 2005 - 12:02 PM

Hav a look at this i think its what you want, i've tried to explain the code

http://www.drk-alias...CODE=view&id=10

hope it helps.

#11 Once

Once

    Young Padawan

  • Members
  • Pip
  • 16 posts

Posted 06 May 2005 - 09:47 PM

there are no topics at all in that forum

#12 Dark

Dark

    Young Padawan

  • Members
  • Pip
  • 68 posts

Posted 07 May 2005 - 06:12 AM

yap no topics yet, but there are tutorials, click tutorials at the top n it should take u to the tutorials page.

Ps: i was updating the forum security n somethin happened but fixin it as i speak, check bac in an hour or two.

I need some more members n people requestin for help :P

#13 Neil

Neil

    Past Staff Member

  • Members
  • Pip
  • 149 posts
  • Gender:Male
  • Location:Australia

Posted 07 May 2005 - 06:45 AM

check out http://zulumonkey.or...=comment&oid=55 theres a very good tutorial on it :P

#14 Dark

Dark

    Young Padawan

  • Members
  • Pip
  • 68 posts

Posted 07 May 2005 - 07:14 AM

create a file called index.php with the following php code
<?php
$id = $_GET['id'];
switch($id) 
{

case "home":
include('home.php');

break; case "page":
include('page.php');

break; case "page2":
include('otherpage.php');

break; case "contact":
include('contact.php');

default:
include('home.php');
}
?>

$id = $_GET['id'];

Change id to whatever u want to use e.g. if u replace id with page it will be index.php?page=urpage

case "home":

the page name so that will be x.php?id=home change home to main n it will be index.php?id=main

include('page.php');

is the link to the page

default:
include('home.php');

main site page so if your main page is main.php change home.php to main.php
if user enters index.php?id=blabla it will take them to that page

To add a new page just add

break; case "thepageid":
include('page.extension');

before default:

:: Summary ::
After you do this you will be able to get to your pages via index.php?id=page

thats wats supposed to be on my site, but might take longer than i wanted to fix,

#15 kraze

kraze

    Young Padawan

  • Members
  • Pip
  • 3 posts

Posted 07 May 2005 - 07:26 AM

create a file called index.php with the following php code

<?php
$id = $_GET['id'];
switch($id) 
{

case "home":
include('home.php');

break; case "page":
include('page.php');

break; case "page2":
include('otherpage.php');

break; case "contact":
include('contact.php');

default:
include('home.php');
}
?>

$id = $_GET['id'];

Change id to whatever u want to use e.g. if u replace id with page it will be index.php?page=urpage

case "home":

the page name so that will be x.php?id=home change home to main n it will be index.php?id=main

include('page.php');

is the link to the page

default:
include('home.php');

main site page so if your main page is main.php change home.php to main.php
if user enters index.php?id=blabla it will take them to that page

To add a new page just add

break; case "thepageid":
include('page.extension');

before default:

:: Summary ::
After you do this you will be able to get to your pages via index.php?id=page

thats wats supposed to be on my site, but might take longer than i wanted to fix,

ty, someone who actually knows the real way :P

#16 Hoot

Hoot

    * Hooty Tooty Fruit *

  • Members
  • PipPipPipPip
  • 1,346 posts
  • Gender:Male
  • Location:Canada
  • Interests:Making Websites, Working in 3D, Playing the Drums

Posted 07 May 2005 - 10:29 AM

well all my scripts work for me :)

#17 Once

Once

    Young Padawan

  • Members
  • Pip
  • 16 posts

Posted 07 May 2005 - 12:58 PM

i will try the one by dark.....hopefully it will work :hi:
I used back in 2003 one time but forgot it when I gave up my site to a friend.........thankyou.

#18 Jaymz

Jaymz

    Retired P2L Staff

  • Members
  • PipPipPipPip
  • 4,104 posts

Posted 07 May 2005 - 01:11 PM

i will try the one by dark.....hopefully it will work :hi:
I used back in 2003 one time but forgot it when I gave up my site to a friend.........thankyou.

The one by Dark is more secure than the rest, so good choice :)

#19 dEcade

dEcade

    P2L Staff

  • P2L Staff
  • PipPipPipPip
  • 1,850 posts
  • Gender:Male
  • Location:Saskatoon, Saskatchewan
  • Interests:Guitar, Programming, Storm Chasing, Games (Designing and playing), Hockey, Photography

Posted 07 May 2005 - 04:31 PM

Here I fixed smardy's script so that it should work:

<?php
if(!$id){
echo ' this is with nothing typed in';
}
if($id == '123info'){
echo 'This is if you put ?id=123info';
}
?>

and if you want more than 1 variable like ?id=123info&user=2 you can use this:


<?php
if($id == '123info' && $user == '2'){
echo 'this is if you put in ?id=123info&user=2';
}
elseif($id == '123info'){
echo 'This is if you put ?id=123info';
}
elseif(!$id){
echo ' this is with nothing typed in';
}
?>

Try that out, it should work.

Also you know that you need to have a server that supports php.

I tested both myself and they work.

dEcade

#20 Once

Once

    Young Padawan

  • Members
  • Pip
  • 16 posts

Posted 09 May 2005 - 12:29 PM

so after I put this in the content area.....if I want to load an info page just make the link http://cloud09.org/index.php?c9=info

or a different page:http://cloud09.org/index.php?c9=different

am I right???




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users