Page 1 of 1
Newbie Question - index.php?id=232323
Posted: Wed Feb 11, 2009 11:32 am
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?
Re: Newbie Question - index.php?id=232323
Posted: Wed Feb 11, 2009 12:02 pm
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.
Re: Newbie Question - index.php?id=232323
Posted: Wed Feb 11, 2009 12:12 pm
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?
Re: Newbie Question - index.php?id=232323
Posted: Wed Feb 11, 2009 12:19 pm
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.
Re: Newbie Question - index.php?id=232323
Posted: Thu Feb 12, 2009 1:39 am
by killingbegin
The index.php?id=232323
its this code
$id = 232323
<ahref="get_vars.php"> ?id=<?php echo $id? ?> </a>