Jump to content

html displaying in textarea?


chandler

Recommended Posts

When I add some text to the front end of the textarea it displays

bla <br/>
bla <br/>
bla <br/> 

How can I stop it from showing the html tags?

Thanks.

 

echo'<textarea id="info" style="width:80%; height:60px;">';
            }
            echo $profile['info'];
            if($_SESSION['user_id'] == $id) {
    echo'</textarea><input type="submit" style="width:70%" 
    value="send" 
    onclick="updateInterests(document.getElementById(\'info\').value)" />';

Link to comment
https://forums.phpfreaks.com/topic/214136-html-displaying-in-textarea/
Share on other sites

echo'<textarea id="info" style="width:80%; height:60px;">';
            }
            echo stripslashes( htmlentities($profile['info'], ENT_QUOTES) );
            if($_SESSION['user_id'] == $id) {
    echo'</textarea><input type="submit" style="width:70%" 
    value="send" 
    onclick="updateInterests(document.getElementById(\'info\').value)" />';

 

stripslashes

htmlentities

echo'<textarea id="info" style="width:80%; height:60px;">';
            }
            $search = array('<br/>', '<br />', '<br>', '<br >');
            $info = str_ireplace($search, "\r\n", $profile['info']);
            echo stripslashes( htmlentities($info, ENT_QUOTES) );
            if($_SESSION['user_id'] == $id) {
    echo'</textarea><input type="submit" style="width:70%" 
    value="send" 
    onclick="updateInterests(document.getElementById(\'info\').value)" />';

 

stripslashes

htmlentities

 

Does that work, if it does, you need to use nl2br on the data when it's posted back.

echo'<textarea id="info" style="width:80%; height:60px;">';
            }
            $search = array('<br/>', '<br />', '<br>', '<br >');
            $info = str_ireplace($search, "\r\n", $profile['info']);
            echo strip_tags($info);
            if($_SESSION['user_id'] == $id) {
    echo'</textarea><input type="submit" style="width:70%" 
    value="send" 
    onclick="updateInterests(document.getElementById(\'info\').value)" />';

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.