Dave
Dave

Reputation: 11

strip HTML from a textarea submitted by user

I am using a plugin called "user submitted posts" - there is a text area which allows user to input the content here is the code :

<li class="usp_content">
            <label for="user-submitted-content" class="usp_label">Your Content</label>
            <div>
                <textarea class="usp_textarea" name="user-submitted-content" id="user-submitted-content" rows="5"></textarea>
            </div>
        </li>

the problem is that this code allows user to input HTML code , like and etc. I tried to strip it from HTML but I just cant figure out how , searched and tried so many codes and it does not work.

I really appreciate if someone tells me how to strip the html from above code so the person cant put html

Upvotes: 0

Views: 1362

Answers (2)

Valeriy Gorbatikov
Valeriy Gorbatikov

Reputation: 3519

You must write something like this

<?php
    $yourTextareaContent = $_POST['user-submitted-content']; // if form METHOD="POST"
    //$yourTextareaContent = $_GET['user-submitted-content']; // if form METHOD="GET"
    echo strip_tags($yourTextareaContent);
?>

Also you have to do it on the server side (php script which receive content from your form).

Upvotes: 1

Sudhir Bastakoti
Sudhir Bastakoti

Reputation: 100175

If using PHP then you could strip html tags using:


echo strip_tags($yourTextareaContent);

See: strip_tags

Upvotes: 0

Related Questions