Stefan83 Posted October 23, 2013 Share Posted October 23, 2013 Hi - I'm trying to echo different results if the current URL contains a certain query string. Ie if the URL contains ?fromAPP=1 OR ?fromQB=1 DO SOMETHING. I can't get the following to work. Can anyone help? Thanks $url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; if (false !== strpos($url,'?fromApp=1,?fromQB=1')) { // do something } else { } Link to comment https://forums.phpfreaks.com/topic/283202-if-query-string-do-something/ Share on other sites More sharing options...
Ch0cu3r Posted October 23, 2013 Share Posted October 23, 2013 Just check whether $_GET variables exist and set to 1 if( (isset($_GET['fromApp']) && $_GET['fromApp'] == 1) || (isset($_GET['fromQB']) && $_GET['fromQB'] == 1) { // url is either ?fromApp=1 OR ?fromQB=1 } Link to comment https://forums.phpfreaks.com/topic/283202-if-query-string-do-something/#findComment-1455054 Share on other sites More sharing options...
Stefan83 Posted October 23, 2013 Author Share Posted October 23, 2013 Thanks but that's throwing errors? Link to comment https://forums.phpfreaks.com/topic/283202-if-query-string-do-something/#findComment-1455055 Share on other sites More sharing options...
Ch0cu3r Posted October 23, 2013 Share Posted October 23, 2013 Sorry, try if( (isset($_GET['fromApp']) && $_GET['fromApp'] == 1) || (isset($_GET['fromQB']) && $_GET['fromQB'] == 1)) { // url is either ?fromApp=1 OR ?fromQB=1 } I left of the closing ) for the if Link to comment https://forums.phpfreaks.com/topic/283202-if-query-string-do-something/#findComment-1455060 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.