CodeIgniter Forums
Special characters issue - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Special characters issue (/showthread.php?tid=74920)



Special characters issue - v1y1 - 11-25-2019

Hello,

I've got a form that I need to pass data through in order to query my database. This form needs to be able to query such things as "qwe#rty," however, if I do this, only "qwe" is being passed through, and everything else is being ignored. 

I don't believe my form is the problem, as it has a redirect, and it redirects correctly (xxx/qwe#rty). But when I attempt to echo my variable that passed 'qwe#rty', it'll only echo 'qwe' and ignore the special character, and anything else after, querying the database with only 'qwe.'

I've tried using $this->uri->segment, and had the same problem. I've also tried urlencode/urldecode, and ended up with the same problem, with % and anything after being ignored.

Thanks in advance if anyone can help.


RE: Special characters issue - jreklund - 11-25-2019

This works great for me:
/index.php/welcome/index/qwe%23rty
PHP Code:
var_dump(urldecode($this->uri->segment(3))); 



RE: Special characters issue - v1y1 - 11-25-2019

(11-25-2019, 01:46 PM)jreklund Wrote: This works great for me:
/index.php/welcome/index/qwe%23rty
PHP Code:
var_dump(urldecode($this->uri->segment(3))); 

This is still only returning 'string(3) "qwe"' for me.


RE: Special characters issue - jreklund - 11-26-2019

Have you tried a clean version of Codeigniter? As it will be hard to debug if you have done customization.

What version PHP are you using? Have you tried to update to the latest one?


RE: Special characters issue - Mr Lister - 11-27-2019

How are you passing the form data?

Once upon a time, for simple database queries based on only one value, I would append the variable to an Ajax $_GET URL.
Thus /controller/method/$variable would be /controller/method/qwe#rty.

This caused problems since anything after the '#' is not sent to the server, it is only used by the browser to link to DOM elements on that same URL.  Sending the Ajax request via $_POST solved it.