codrgi Posted April 5, 2009 Share Posted April 5, 2009 I currently have a few $_GET[''] and need help on how to redirect someone to the index.php if they try a $_GET[''] that dosent exist, does anyone know how to do this? Link to comment https://forums.phpfreaks.com/topic/152682-how-to-redirect-if-the-_getenteractionhere-dosent-exist/ Share on other sites More sharing options...
corbin Posted April 5, 2009 Share Posted April 5, 2009 You could make an array of $_GETs that are allowed and then check if each $_GET is in there. Like so: $allow_get = array('something', 'something_else'); foreach($_GET as $key => $val) { if(!in_array($key, $allow_get)) { header("Location: http://somewhere.com/somepage.php"); exit; } } But I have to wonder why you care if someone makes up a $_GET. Does it pose a security threat to your application? It shouldn't x.x. Link to comment https://forums.phpfreaks.com/topic/152682-how-to-redirect-if-the-_getenteractionhere-dosent-exist/#findComment-801813 Share on other sites More sharing options...
JD* Posted April 5, 2009 Share Posted April 5, 2009 I like to use case statements to call my functions. switch($_GET['action']) { case "email": //do email action here break; default: // redirect to home break; } Link to comment https://forums.phpfreaks.com/topic/152682-how-to-redirect-if-the-_getenteractionhere-dosent-exist/#findComment-801817 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.