This question already has answers here:
CodeIgniter PHP Framework - Need to get query string
(12 answers)
How can I read a QueryString in CodeIgniter?
(3 answers)
Closed 9 years ago.
Using Chargify with Codeigniter framework. On completion of signup with Chargify, the return URL can be set with parameters. It seems that these parameters can only be returned ?id=123&ref=321. With Codeigniter, how do I grab those return paramenters?
http://www.website.com/confirmation?id=3163255&ref=5159c58278a1f
CodeIgniter, by default, destroys the $_GET variable that one would usually use to access the parameters in a URL.
This line will parse the URL and populate the $_GET array with the URL's parameters. It's useful for when you want to selectively use the $_GET array in a CodeIgniter project, rather than having to enable CodeIgniter's query strings, which would be globally and continually active.
parse_str(substr(strrchr($_SERVER['REQUEST_URI'], "?"), 1), $_GET);
It can then be accessed as you would normally access an array, for example:
$id = $_GET['id'];
$ref = $_GET['ref'];
Related
This question already has answers here:
How do I make a redirect in PHP?
(34 answers)
Closed 6 years ago.
I need to redirect dynamic URL like this "https://test.com?user=abc#gmail.com" to "https://test.com"
If I understand correctly, this URL is coming dynamically with a query string. And you want to remove the query string portion and redirect to this modified URL.
Let's assume the dynamic URL is stored in a variable $url.
Try this:
$url = "https://test.com?user=abc#gmail.com";
$modified_url = strstr($url, "?", true); // Remove the query string, which results in https://test.com
header("location:".$modified_url); // Redirect to the modified URL.
You can store the dynamic part in a variable and use the header() function to redirect your user.
$dynamicPart = "someguy#somedomain.com";
header("Location: https://test.com/index.php?username=".$dynamicPart);
exit;
This question already has answers here:
GET URL parameter in PHP
(7 answers)
Get the full URL in PHP
(27 answers)
Closed 6 years ago.
I would like to capture the lang variable and then translate the page based on this variable.
global $jwp_lang;
$url = $_SERVER["REQUEST_URI"];
echo $url;
for example if the url contains http://localhost/about/?lang=fr I would like to capture this value.
You can easily capture the value of lang variable using php Super Global variable $_GET :
$lang = $_GET['lang'];
echo $lang;
It is better to pass the URL parameters using add_query_var, and get the parameter using get_query_var.
Because, they can handdle the set, and get of multiple parameters, and is the recommended way of getting URL passed as parameters.
This question already has answers here:
GET URL parameter in PHP
(7 answers)
Closed 7 years ago.
I have a client url[www.mysite.com/page.aspx]
when we put this url in browser then it revert the automatically
with this url
[www.mysite.com/page.aspx?|&CC=121&DD=123&AA=323|&CC=321&DD=555&AA=000]
Now we want to fetch that parameter value in php page through php or jquery.
Kindly Help and give the best suggestions.
You can simply use GET
$cc = $_GET['CC'];
$dd = $_GET['DD'];
You can access those values using $_REQUEST or $_GET
This question already has answers here:
How to get GET (query string) variables in Express.js on Node.js?
(26 answers)
Closed 9 years ago.
What is node.js equivalent of
$_SERVER['QUERY_STRING']
and also to put it in:
list($a,$b,$c ...) = explode('/', $_SERVER['QUERY_STRING']);
See the answer here for how to get the query string: How to get GET (query string) variables in Express.js on Node.js?
Then use querystring.parse() to get an object representing the keys and values in the query string.
http://nodejs.org/api/querystring.html#querystring_querystring_parse_str_sep_eq_options
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
# in url getting ignored in php 5.2
I have following link on webpage. Here I am sending return(/profile?id=6#contacts) as url param to return back after operation complete. But it is sending only /profile?id=6 to verify.php script.
http://example.com/verify.php?id=1&sessionId=6&return=/profile.php?id=6#contacts
I know that hash value is not passed to server but I want to know that is there any way to pass compelete return param to server with # value.
Thanks
You need to urlencode() the entire return parameter.