Hi guys! I have most of my pages created using arrays & variables but i am displaying all of them in this form >> mypage.php?getdata=0&todata=10 it works fine but, when we open mypage.php , the data doesn't come because we have nothing in it.. what i want is, when people try to enter mypage.php in address bar, they are automatically moved to mypage.php?getdata=0.... i tried header, include but didnt work.. any other solution or ideas will surely be appreciated. ..
Try something like this: function getRequestParameter($name, $default=null) { return array_key_exists($name, $_REQUEST) ? $_REQUEST[$name] : $default; } PHP: Then when you're referencing your query string variable do this: $getdata = getRequestParameter("getdata", 0); PHP: That way if it doesn't exist it will get assigned the default value. I use this all the time in my scripts.
sorry, not working for me or do i need to change the values? when i try to change its values it gives some error. you edit this code to meet my page requirements. For example: my page is: mypage.php i want to redirect to: mypage.php?getdata=0&todata=10 thnx