Welcome Guest, Not a member yet? Register   Sign In
Insert html/js in db and edit
#1

HI , sorry for english , hi want to save in my db a code like this :

PHP Code:
var uri 'https://pippo.com' + new String (Math.random()).substring (211);
                            
document.write('<a href="pippo.com" target="_BLANK"><img src="'+uri+'" border=0></a>'); 

This is a js script , hi want treat it like simple text , booth insertion and edit .

To try , i insert directly this code in db but if i echo the code i see a clickable image .

How can i save it as simple text and show as simple text ?
Reply
#2

If you want to render it (so you can edit it). You will need to echo it inside a <textarea>your code</textarea>. In case you wan't to display it (for a programming guide?) you can use html_escape('your code').
Reply
#3

(This post was last modified: 01-21-2020, 11:31 AM by pippuccio76.)

(01-21-2020, 11:17 AM)jreklund Wrote: If you want to render it (so you can edit it). You will need to echo it inside a <textarea>your code</textarea>. In case you wan't to display it (for a programming guide?) you can use html_escape('your code').

Thanks i solve it , for show in list i use :


<?= htmlspecialchars($row->codice)?>

To show in input i use :


$val=htmlentities($record->codice)

and 

<input class='form-control' type='text' value="<?=$val?>"  id='id_class_codice'  name='codice' maxlength='65535'  >
Reply




Theme © iAndrew 2016 - Forum software by © MyBB