problem with single quote in input field - 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: problem with single quote in input field (/showthread.php?tid=68257) |
problem with single quote in input field - nunenthal - 06-16-2017 Hello, I have this value in database : test'test When I try to display the text in a field I get this in the input field : test'test If I display my variable in the html flux i get : test'test width no problem. My code : echo $projets['mo'].'<br>'; // display test'test $field=array('type'=>'text', 'name'=>'mo','value'=>set_value('mo',$projets['mo']), 'size'=>'64','maxsize'=>'255'); echo form_input($field); // display test'test Please help, RE: problem with single quote in input field - skunkbad - 06-16-2017 Are you expecting a problem? What is the problem? Please clarify. RE: problem with single quote in input field - marksman - 06-16-2017 I think this may help you http://php.net/manual/en/function.stripslashes.php RE: problem with single quote in input field - nunenthal - 06-16-2017 (06-16-2017, 10:26 AM)skunkbad Wrote: Are you expecting a problem? What is the problem? Please clarify. If fact if I use form_input() it's not working. I get test'test in the input form If I not use form input I get the correct text in my input field test'test exemple : I can replace this $a="test'test"; $field=array('type'=>'text', 'name'=>'test','value'=>set_value($a), 'size'=>'64','maxsize'=>'255'); echo form_input($field); By $a="test'test"; $b=set_value('test',$a); echo '<input type="text" name="test" value="'.$b.'" size="64" maxsize="255">'; And it's working, But why I can't use form_input(); it's a bug ? RE: problem with single quote in input field - Wouter60 - 06-16-2017 It's the combination of form_input and set_value. Both functions "escape" the value. You can turn off html escaping in set_value, by adding a third parameter: PHP Code: set_value('mo',$projets['mo'],FALSE) Otherwise, build the input field with plain html. Then it's possible to use set_value for repopulating the field after form validation. PHP Code: <input type="text" name="test" value="<?= set_value('test','default_value');?>" size=64 maxlength=255 /> RE: problem with single quote in input field (resolved) - nunenthal - 06-17-2017 (06-16-2017, 11:27 PM)Wouter60 Wrote: It's the combination of form_input and set_value. Both functions "escape" the value. Hello, it's working by adding the false parameter, thank's for all. |