Newbie Question - index.php?id=232323

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Anarking
Forum Newbie
Posts: 24
Joined: Wed Feb 11, 2009 11:29 am

Newbie Question - index.php?id=232323

Post by Anarking »

Hi there


New to PHP and was just wondering could anyone point me towards a tutorial on creating pages like my example in the title?


Im trying to make a program that will allow the user to specify some values and create a page where all these values can be entered later by different people.


Can someone point me to a tutorial or such that includes that?
semas
Forum Newbie
Posts: 10
Joined: Sat Oct 25, 2008 11:00 am

Re: Newbie Question - index.php?id=232323

Post by semas »

Hi, thet is basicly $_GET[] function. I will not explain it to you just give you link to the basic tutorial.
http://www.w3schools.com/PHP/php_get.asp

And here is my example code:

Code: Select all

<?php
$page = $_GET['id'].".php";
if(file_exists("pages/".$page)){ //check if page exists
    include("pages/".$page); //include file to main index file
}else {
    echo "Page not found"; //display error message if file not found
}

Code: Select all

all pages should be stored in folder called 'pages'
file names should be something like: 1.php, 2.php, ... 193.php, ... and soo on
and url would look like 'index.php?id=1344567'
Hope that will help.
Last edited by semas on Wed Feb 11, 2009 12:14 pm, edited 1 time in total.
Anarking
Forum Newbie
Posts: 24
Joined: Wed Feb 11, 2009 11:29 am

Re: Newbie Question - index.php?id=232323

Post by Anarking »

But is there a way of having it say something like index.php?id=434343 instead of all the variables? Or does id just refer to an array with all the variables in it?
semas
Forum Newbie
Posts: 10
Joined: Sat Oct 25, 2008 11:00 am

Re: Newbie Question - index.php?id=232323

Post by semas »

$_GET['id'] will be same as in url.
For example:

Code: Select all

url: '[color=#4080BF]index.php?id=13456[/color]' [color=#408000]=>[/color] $_GET['id'] = [color=#4040BF]13456[/color]
url: '[color=#4080BF]index.php?id=123455[/color]' [color=#408000]=>[/color] $_GET['id'] = [color=#4040BF]123455[/color]
url: '[color=#4080BF]index.php?id=12asdas[/color]' [color=#408000]=>[/color] $_GET['id'] = [color=#4040BF]12asdas[/color]
Sorry i didnt understand what did you wanted to know. if you explain it more ill try to help you.
killingbegin
Forum Newbie
Posts: 20
Joined: Sun Feb 08, 2009 5:07 am

Re: Newbie Question - index.php?id=232323

Post by killingbegin »

The index.php?id=232323
its this code
$id = 232323
<ahref="get_vars.php"> ?id=<?php echo $id? ?> </a>
Post Reply