• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Edit value on db with ' or "

#1
hi , sorry for english , if i want t a value inserted by textarea i have problem with '  .

This is the code :


Code:
 <input class='form-control' type='text' value='<?=$val?>' id='id_class_descrizione_problema' name='descrizione_problema' maxlength='65535' >

$val is a value from db .
How can i prevent error textwith ' or " or \ ?
Reply

#2
PHP.NET - htmlspecialchars

PHP.NET - htmlentities
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
This is not the right html code for a textarea. What you should do is this:
PHP Code:
<textarea name="descrizione_problema" id="id_class_descrizione_problema" class="form-control" rows="12" maxlength="65535">
<?= 
$val;?>
</textarea> 
Reply

#4
Use the esc() helper function:

PHP Code:
<input type="text" name="myfield" value="<?= esc($string); ?>" /> 
Test your translation files with Translation Tester
Reply

#5
@includebeer, that's a CI 4 method. You can use html_escape(value), or form_prep().
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#6
(08-05-2019, 08:56 AM)InsiteFX Wrote: @includebeer, that's a CI 4 method. You can use html_escape(value), or form_prep().

Yeah, but people should really develop new projects with CI4!  Big Grin
Test your translation files with Translation Tester
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


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