Welcome Guest, Not a member yet? Register   Sign In
INPUT CLASS destroys global get?
#9

[eluser]judico[/eluser]
Here is my solution to the occasional need to acquire a querystring parameter value from a GET request.

Note: $config['enable_query_strings'] = FALSE; in my config.php

Code:
/**
*url querystring parameter
*ADDED to CI url_helper.php by Kevin Davis 4/10/09
*retrieve a querystring value from a GET request
*
*Location: ./system/helpers/url_helper.php
*
*@access public
*@param string
*@return string
*/
if ( ! function_exists('querystring_get_param_value'))
{
    function querystring_get_param_value($key)
    {
        //This codeblock acquires a querystring value from the $_SERVER array.
        preg_match("/[?&]" . $key . "=([^&$]*)/", $_SERVER['REQUEST_URI'], $matches);

        if(count($matches) == 2){
            $value = urldecode($matches[1]);
        }
        else{
            $value = '';
        }
        
        return $phrase;
    }
}


//after adding this function to url_helper.php you can simply do the following

$value = querystring_get_param_value('txt');

//$value will equal 'foo' for something like example.com/sample?txt=foo

//Hope someone finds this useful.


Messages In This Thread
INPUT CLASS destroys global get? - by El Forum - 04-07-2009, 03:23 PM
INPUT CLASS destroys global get? - by El Forum - 04-07-2009, 04:15 PM
INPUT CLASS destroys global get? - by El Forum - 04-07-2009, 04:21 PM
INPUT CLASS destroys global get? - by El Forum - 04-07-2009, 04:50 PM
INPUT CLASS destroys global get? - by El Forum - 04-07-2009, 05:20 PM
INPUT CLASS destroys global get? - by El Forum - 04-07-2009, 08:54 PM
INPUT CLASS destroys global get? - by El Forum - 04-07-2009, 10:11 PM
INPUT CLASS destroys global get? - by El Forum - 04-07-2009, 11:07 PM
INPUT CLASS destroys global get? - by El Forum - 04-10-2009, 12:12 PM
INPUT CLASS destroys global get? - by El Forum - 04-10-2009, 12:15 PM
INPUT CLASS destroys global get? - by El Forum - 04-10-2009, 12:18 PM
INPUT CLASS destroys global get? - by El Forum - 04-10-2009, 12:46 PM
INPUT CLASS destroys global get? - by El Forum - 04-10-2009, 12:59 PM
INPUT CLASS destroys global get? - by El Forum - 04-10-2009, 01:01 PM
INPUT CLASS destroys global get? - by El Forum - 04-10-2009, 01:19 PM
INPUT CLASS destroys global get? - by El Forum - 04-10-2009, 01:31 PM
INPUT CLASS destroys global get? - by El Forum - 04-10-2009, 02:10 PM



Theme © iAndrew 2016 - Forum software by © MyBB