is it good to ask whats the use of id while working with php.... if u talk abt property . whose property is it.. the link of the present web page or that of the destination page that the codes makes the page to get redirected..........

more elaborate your Ques with an example..???
are you talking about Id which u get from database...??? :)

hiiiiiiiiiiii................. i m talking abt the id which is associated with the page of the present web page....................like...........
<a href="edit_page.php?id=<?php echo $tyu; ?>">MAKE CHANGES IN THE RECORD</a>

nostalgia149,
It's called query string. It is used to pass some information/data between page request.

The id to which you refer can mean ANYTHING. Using 'id' in the querystring is just force of habit for most programmers when you want to pass a variable such as member id, page id etc. In these instances, the 'id' is often used for data retrieval from a database or a file. A common usage for this would be to get a record or records from a database table which has a field that has that particular id value.

pHp uses the $_GET variable, in this instance the $_GET variable, to pass on the data from one page to another as mentioned by adatapost.

Good question.

The id to which you refer can mean ANYTHING. Using 'id' in the querystring is just force of habit for most programmers when you want to pass a variable such as member id, page id etc. In these instances, the 'id' is often used for data retrieval from a database or a file. A common usage for this would be to get a record or records from a database table which has a field that has that particular id value.

pHp uses the $_GET variable, in this instance the $_GET variable, to pass on the data from one page to another as mentioned by adatapost.

Good question.

thanks ardav... so id is mainly for linking two pages using a common entity .. is it???????? where else is it useful apart frm this n common applications?????????????????

You may use $_REQUEST for the same.

hi.. adatapost... with the little understanding of php wht i hav understood is that.. we use request whn v use certain data frm the same page and use the database.. in case of post v use it whn v hav to get the data frm a different page.. forget get for the time being.... how far is my conception right??????????????/

The 'id' to which you refer, is meaningless. It's just a name (or 'key') in a querystring (the bit at the end of the url following '?') to which you can assign a value, which can be almost anything.

e.g. If this is your website and you wanted to send info to a page to delete an user:

http://www.example.com/delete.php?id=12389&confirmcode=hy6io98

You could equally have used:

http://www.example.com/delete.php?user=12389&confirm=hy6io98

You would then, in this instance use $_GET in your delete.php file to get at the data (12389) as opposed to using $_GET in the first example.

$_GET can also be used with forms if you set the 'method' attribute to 'get'. I would advise against this, use 'post' if possible.

adatapost may get back to you about $_REQUEST, so I won't step on his toes by giving an explanation.

So the querystring (rather than calling it the 'id'), is a way of passing data to the page in question.

BTW: you wouldn't necessarily delete an user through a querystring, there are more secure ways of doing this.

Just be very careful when working with values passed in the GET & POST arrays . Its extremely easy for them to be modified by the user and you have to be fully aware of this.

Probably the most common thing i've seen is the usage of $_GET and $_POST in queries or being used to dynamically include files in their raw, straight from the url, forms.

Just be very careful when working with values passed in the GET & POST arrays . Its extremely easy for them to be modified by the user and you have to be fully aware of this.

Probably the most common thing i've seen is the usage of $_GET and $_POST in queries or being used to dynamically include files in their raw, straight from the url, forms.

Precisely. This is why you should always pass a hashed key-value along with the other key-values. Probably the best known is md5, but you should use a 'salt'. Example:

http://www.example.com/delete.php?user=56

The above could be generated by a link on a different page, but could easily be modified by an user to 'user=67' etc and create havoc. You'd need to add somehting like a confirmation code:

http://www.example.com/delete.php?user=56&confirm=hsy692jsygbkchy279hscuybew0po3y7

This 32-character code can be generated like this:

<?php
$usr = "7";
$salt = "gibberish";
$cf = md5($usr . $salt); 
?>
<a href="delete.php?<?php echo "user={$usr}&amp;confirm={$cf}";?>">delete me</a>

In the delete.php page, you'd then check the user value against the confirm code:

if($_GET['conf'] == md5($_GET['user'] . 'gibberish'){
    ..do your stuff..
}

That's a very simple usage, for extra security you'd want something a little more secure again, e.g. double hashes or pseudo-random salts.

md5 is a one-way thingy, you can't 'un-md5' and get your original data, well not very easily anyway.

This article has been dead for over six months. Start a new discussion instead.