Hi can i ask something ,i found it here in sitepoint how to do this in php like url
when every time i click on the link it shows
when i call my page it only gives me like this in url www.mypage.com/gallery.php
there is no
can you help me on this how to achieve like this to have ?do=somvariable
Thank you in advance.
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.
For example (using your query string above):
echo $_GET['do']; //outputs "variable" (beware of XSS attacks)
One caveat to watch out for when using the HTTP GET request (especially for actions) is CSRF attacks.
Hi, Thank you for the reply, can you please elaborate more your example, i am confuse,Thank you in advance.
How do i know what page will be loaded in the variable of "do"
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
I want to know how i can accomplish like that,if i click the link edit profile
the url must be like this
and then it will load the profile form.
just like in the sitepoint,and also it loads the form in the right side.
I hope you got me now.
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
default: //default behavior, if none of above options is located in 'do'
Hi thank you for the reply, Oh! so this how to do it...now i know,last thing,why did you test !empty ? instead of isset ?
THank you in advance.
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.
This topic is now closed. New replies are no longer allowed.