Page 1 of 1

simple question

Posted: Wed Mar 28, 2012 3:34 pm
by red wolf
i have form the the user can enter his own comment by post form.
i have file comment.php that working on this file.
i want that the file will excute all option to right html/php/mysql and other tags.
i mean that its will not be possible to write in comment code that will do any script.
somebody have ideas for me please?

Re: simple question

Posted: Wed Mar 28, 2012 3:39 pm
by Celauran
Do you mean strip_tags()?

Re: simple question

Posted: Wed Mar 28, 2012 3:50 pm
by red wolf
Man.
THANK YOU VERY MUCH!
Best Helping Board in the world!

Re: simple question

Posted: Wed Mar 28, 2012 3:56 pm
by phphelpme
Why not use something like my code below which will give you choice of what is accepted or not etc

Code: Select all

$string = "This IS a STring that has Ma£NY different cases, and even (including& characTers that you migHT not WANT To AppeaR! %^&%*&&^%^%^%£^*)*";

function replace($replace) { // CREATES THE REPLACE FUNCTION TO CALL ANYTIME
$replace = strtolower($replace); // MAKE ALL CHARACTERS LOWERCASE
$disallowed = array("!", "£", "$", "%", "^", "&", "*", "(", ")", "_", "+", "-", "=", "{", "}", "[", "]", ":", ";", "@", "'", "~", "#", "<", ",", ">", ".", "?", "/", "|", "`", "¬", "\\"); // DISALLOWED CHARACTERS
$stripped = str_replace($disallowed, "", $replace); // REPLACE DISALLOWED CHARACTERS WITH "" I.E. NOTHING!
return $stripped;
}

$string_result = replace($string); // CALLS THE REPLACE FUNCTION ON THE VARIABLE $STRING

echo $string_result;

// RESULT BEING: this is a string that has many different cases and even including characters that you might not want to appear
This way you can choose which characters you want to allow and which ones you do not. It is not exactly what you are looking for but will give you a great tool that will give you more control over what is accepted or not.

Best wishes

Re: simple question

Posted: Wed Mar 28, 2012 4:25 pm
by red wolf
nice!
thanks!