sico87 Posted October 1, 2009 Share Posted October 1, 2009 Hi there I am hoping some will be able to able me, I current have a website that retrieves data from a database using a querystring from the URL something like this "products/product.php?ptid=5&pid=52" I am trying to re-skin one of the pages depending on the ptid, do this I check agains the URI that the ptid=5 in the URL. However this check is failing when the user click on a product as the URI is changing. Is there a way that I can limit my script so that diregards anything after ptid=5? I currently have something like this, $uri = $_SERVER['REQUEST_URI']; if ($uri == '/products.php?ptid=5') { $class-name = "class"; ......etc } I have no idea how I can limit how far it looks into the URI can anyone help? Link to comment https://forums.phpfreaks.com/topic/176167-solved-_serverrequest_uri/ Share on other sites More sharing options...
cags Posted October 1, 2009 Share Posted October 1, 2009 However this check is failing when the user click on a product as the URI is changing. Can you just clarify what you mean by this? Do you mean if they click a link as the page is still loading? That's what it sounds like you mean, but that doesn't make a great deal of sense to me. Also is that URL actually in the address bar, or is it created by a htaccess redirect? Link to comment https://forums.phpfreaks.com/topic/176167-solved-_serverrequest_uri/#findComment-928368 Share on other sites More sharing options...
Evilace Posted October 1, 2009 Share Posted October 1, 2009 if ($uri == '/products.php?ptid=5') { $class-name = "class"; ......etc } put alternate clause for pages greater than you want if ($uri > '/products.php?ptid=5') { echo"invalid"; } just play with it, maybe it will help Link to comment https://forums.phpfreaks.com/topic/176167-solved-_serverrequest_uri/#findComment-928371 Share on other sites More sharing options...
sico87 Posted October 1, 2009 Author Share Posted October 1, 2009 However this check is failing when the user click on a product as the URI is changing. Can you just clarify what you mean by this? Do you mean if they click a link as the page is still loading? That's what it sounds like you mean, but that doesn't make a great deal of sense to me. Also is that URL actually in the address bar, or is it created by a htaccess redirect? Sorry I dont think I explained it very well, When the user first lands on the page the URI is /products.php?ptid=5 if the user then clicks on a product the URI changes to /products.php?ptid=5&pid=7. My issue is that while the user is at /products.php?ptid=5 my conditional statement checking that the URI matches /products.php?ptid=5 returns true if however the URI is /products.php?ptid=5&pid=7 it fails I need to be able to somehow use the /products.php?ptid=5 from /products.php?ptid=5&pid=7 so that my check returns true whatever happens as long as some of the URI is products.php?ptid=5 hope that makes more sense. Link to comment https://forums.phpfreaks.com/topic/176167-solved-_serverrequest_uri/#findComment-928378 Share on other sites More sharing options...
cags Posted October 1, 2009 Share Posted October 1, 2009 Is there a reason you can't use... <?php if(isset($_GET['ptid']) && $_GET['ptid'] == 5) { ?> Link to comment https://forums.phpfreaks.com/topic/176167-solved-_serverrequest_uri/#findComment-928383 Share on other sites More sharing options...
sico87 Posted October 1, 2009 Author Share Posted October 1, 2009 cags you genious!! I have no idea why I didn't think of that!!! Link to comment https://forums.phpfreaks.com/topic/176167-solved-_serverrequest_uri/#findComment-928386 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.