0

Given this link:

localhost/abc/review?coupon=bskgnlsdgkj

How do I get the coupon value inside view?
I tried $_GET['coupon], but it didn't work.

showdev
  • 28,454
  • 37
  • 55
  • 73
cpp tpo
  • 13
  • 3
  • You can check input parameter by using `$this->input->get('name_of_the_parameter');` https://codeigniter.com/user_guide/libraries/input.html – Maharramoff Jan 18 '20 at 21:32
  • And inside view you can do as follows. `$ci =& get_instance(); $ci->input->get('coupon');` https://codeigniter.com/user_guide/general/ancillary_classes.html?highlight=get_instance#get_instance – Maharramoff Jan 18 '20 at 21:38
  • please have a look at this docs: https://codeigniter.com/user_guide/libraries/uri.html – Vickel Jan 19 '20 at 00:40
  • I think this question is duplicated with this one? https://stackoverflow.com/questions/37042468/how-to-get-value-from-url-in-codeigniter – The Anh Nguyen Jan 20 '20 at 07:53
  • Does this answer your question? [How to make CodeIgniter accept "query string" URLs?](https://stackoverflow.com/questions/2894250/how-to-make-codeigniter-accept-query-string-urls) – Don't Panic Jan 20 '20 at 09:50

1 Answers1

0

You can use $this->input->get('coupon'); to get the value of url parameter. But, I suggest you to get the parameter value with $this->input->get('coupon',TRUE); to applying XSS Security directly.

For information can be found on this link.

Shawn
  • 1,232
  • 1
  • 14
  • 44
Farhan
  • 253
  • 2
  • 9