The part you’re referring to is called the query string, and is created via the HTTP GET request. In your example above, the do part of the string is a key in the superglobal $_GET array, and the part to the right of the equals sign is the corresponding value.
Can you tell us what exactly are you trying to do? You can’t know what will be in “do”, you generate links with “do” filled out when you generate the page itself. However, note that users can place anything in there, that’s why @tpunt wrote “(beware of XSS attacks)”. You need to sanitize this variable if you’re outputting it to the browser or do include/require based on this.
Hi, Okay sorry for my bad english,…i will try my best to explain you this…when I was navigating in the settings in my control panel i found out that in the left pane there is menu like my setting,my subscription etc…,…under my settings i clicked those links like edit profile,edit avatar,etc…and i found out in the url something like this
profile.php?do=editavatar
profile.php?do=editprofilepic
I want to know how i can accomplish like that,if i click the link edit profile
the url must be like this
profile.php?do=editprofile
and then it will load the profile form.
just like in the sitepoint,and also it loads the form in the right side.
Now make files first.php, second.php and third.php with different content inside. You should also make 404.php for “not found” pages. Then in index.php place following code:
//you can place links in this file also
if (!empty($_GET['do']))
{
switch($_GET['do']) {
case 'first':
include 'first.php';
break;
case 'second':
include 'second.php';
break;
case 'third':
include 'third.php';
break;
default: //default behavior, if none of above options is located in 'do'
include '404.php';
}
}
It’s just my way of checking things, you may freely (and probably should) use isset() here. !empty() is not same as isset(), but in certain occasions it has same result. E.g. if someone opens index.php?do= it will be set, but it will also be empty… in other words in such case the isset() check would go through, but !empty() would not.
edit: Actually, when I think about it, isset() is mandatory here. Without it you’ll get unwanted notices from PHP.