Welcome Guest, Not a member yet? Register   Sign In
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); ?>" /> 
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
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, 07: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
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply




Theme © iAndrew 2016 - Forum software by © MyBB