October 16th, 2013, 05:44 AM
Generating a link to SQL information
Okay once again; sorry if I fail to make myself clear but I am new to SQL and I am still learning..
So if I make a SQL table with profiles of users who use my website, I want other people to be able to see their profiles.
If I check the link to my own profile on this forum, it's this:
As far I understand it, the "u" is a variable(???) that I use to search for a profile while the 481940 is the primary key of my account in the table (???). Now how can I create a similair system?
So in example:
would lead to the account of the player.
October 16th, 2013, 06:07 AM
it's actually very simple. The "u=..." stuff after the question mark is indeed a parameter. In PHP, you can retrieve the value of the parameter with
This value can then be used in a database query.
Check out this tutorial on PDO which explains how to do this securely. Note that you cannot simply insert the variable into the query string, because then any visitor would be able to manipulate the query and access the database directly.
October 16th, 2013, 06:10 AM
So in fact I can do it like this:
Then at anypage.php I will process the "u"?
October 16th, 2013, 06:43 AM
Yes. You specify any number of parameters in the URL.
For example, my URL currently says
So there's three parameters: do, noquote and p. This tells the current script what to do.
October 16th, 2013, 07:21 AM
Thank you! I tried it on a page without the queries and it seems to work so far! I guess I can figure out the rest myself. Thanks a lot!