CodeIgniter Forums
How to pass value into URL? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How to pass value into URL? (/showthread.php?tid=55782)



How to pass value into URL? - El Forum - 11-09-2012

[eluser]whygod[/eluser]
hi guys

I want to pass a value into URL.
Let say that variable name is $email_tmp.

and the value is,
$email_tmp = '[email protected]';

How to pass $email_tmp into link URL?

Thanks in advanced.










How to pass value into URL? - El Forum - 11-09-2012

[eluser]robertorubioes[/eluser]
Hi,

You try it?

http://domain.com/controller-foo/method-foo/[email protected]

I think you need know "GET" protocol HTTP.

But also you view
http://ellislab.com/codeigniter/user-guide/libraries/input.html
Code:
$this->input->get()



How to pass value into URL? - El Forum - 11-09-2012

[eluser]PhilTem[/eluser]
Code:
redirect(urlencode('example.com/controller/method/?email=' . $email_tmp));

even though I would not recommend too extensively passing data via URI parameters. You've got sessions which can store data more securely plus it won't escape the strings.

PS: Or a little more fancy techniques used:
Code:
$uri_params = array('email' => $email_tmp);
redirect(urlencode('example.com/controller/method/' . http_build_query($uri_params)));