vjgopinath Posted August 21, 2010 Share Posted August 21, 2010 Hi All, I am pretty new to PHP ( I am a C Programmer). I am trying a simple shopping cart website for my friend. IN one of the pages, I am submitting some info, which is actually not showing up in my server side php. Below is the HTML code to submit. <a href="cart.php?action=add&p=5&size=small"> <img src="images/add_to_cart.gif"/> </a> I tried to check the values of the parameters using $action = $_GET['action'] ; Action stored empty. Then I checked the whole array print_r($_GET) which returned Array( ) So, for some reason the value is always empty. I tried the declaration GLOBAL $_GET, but no use. Any help/directions - much appreciated! Quote Link to comment https://forums.phpfreaks.com/topic/211368-_get-returns-empty-always/ Share on other sites More sharing options...
PFMaBiSmAd Posted August 21, 2010 Share Posted August 21, 2010 Does the URL in the browser address bar display the expected URL with the ?action=add&p=5&size=small on it? If it does, then your code is probably overwriting the $_GET variables. If you want someone here to directly help with what your code might be doing, just post your code for the quickest solution. The global keyword ONLY has meaning when used inside of a function definition (and even there it should not be used at all for well written code.) Using it on one of php's already superglobal variables, like $_GET, actually creates a new set of variables that DON'T have the values from the actual superglobal variable. Quote Link to comment https://forums.phpfreaks.com/topic/211368-_get-returns-empty-always/#findComment-1102085 Share on other sites More sharing options...
vjgopinath Posted August 24, 2010 Author Share Posted August 24, 2010 Hi PFMaBiSmAd, I checked the URL bar and found the parameters missing when I click "Buy Now" button. I have attached the php code and the resulting html output for further check. Thanks a lot! [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/211368-_get-returns-empty-always/#findComment-1103138 Share on other sites More sharing options...
PFMaBiSmAd Posted August 24, 2010 Share Posted August 24, 2010 The HTML output that you posted works (produces the expected URL.) A few possibility exist that you would need to check out - 1) You are doing some URL rewriting and the GET parameters on the end of the URL are not being passed through, 2) The page that is the target of the URL is redirecting either back to itself or to another page and it is not passing the GET parameters on the end of the URL. Quote Link to comment https://forums.phpfreaks.com/topic/211368-_get-returns-empty-always/#findComment-1103161 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.