theprogrammer theprogrammer - 1 year ago 47
PHP Question

don't allow user to access profile.php but allow him to access profile.php?username=

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

Answer Source

Well you could check if the ?username= exists by doing:

    // The user tried to access profile.php?username=
    // The user went to profile.php

For more information about $_GET: