• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Special characters issue

#1
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.
Reply

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

#3
(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.
Reply

#4
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?
Reply

#5
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.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.