i know the question is a bit weird but i don't want user to access profile.php without there being the ?username. because it displays notice that username isn't defined. is there anyway i can do that? for example user clicks on username he gets redirected to profile.php?username=y but i don't want him to type in the url profile.php. if he does that i want to redirect him to another page is that possible. i tired getting the url and if it's profile.php only i want to redirect him but if it has ?username in it i want to show the profile page
Well you could check if the ?username=
exists by doing:
if(isset($_GET['username'])){
// The user tried to access profile.php?username=
}else{
// The user went to profile.php
}
For more information about $_GET
:
http://php.net/manual/en/reserved.variables.get.php