theprogrammer theprogrammer - 4 months ago 6x
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


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: