happypete Posted September 13, 2012 Share Posted September 13, 2012 Hi, I have a photo gallery that I was updating with the following code, but want to implement the htmlpurifier instead // Update galley title and orders $sql = "UPDATE photos SET description=?, rank=? WHERE id=? AND siteid=?"; $stmt = $db->prepare($sql); if(count($_POST['rank']) > 0) { foreach($_POST['rank'] AS $key => $val) { $stmt->execute(array( htmlentities(str_replace(array('/iframe', '/script'), '', $_POST['description'][$key])), $val, $key, $siteid) ); } } I need to use htmlpurifier on each $_POST['description'] but haven't got a clue how to implement it. require ('htmlpure/HTMLPurifier.standalone.php'); $config = HTMLPurifier_Config::createDefault(); $purifier = new HTMLPurifier($config); $clean_html1 = $purifier->purify(stripslashes($_POST['description'])); Do I need to put the '$_POST['description']' into an array first to apply the htmlpurifier, if so how do I go about doing that? Quote Link to comment https://forums.phpfreaks.com/topic/268329-using-htmlpurifier-with-foreach/ Share on other sites More sharing options...
darkfreaks Posted September 13, 2012 Share Posted September 13, 2012 http://stackoverflow.com/questions/2677578/php-html-purifier-hello-world-world-tutorial-striptags Quote Link to comment https://forums.phpfreaks.com/topic/268329-using-htmlpurifier-with-foreach/#findComment-1377624 Share on other sites More sharing options...
happypete Posted September 13, 2012 Author Share Posted September 13, 2012 Solved it. I added the following: require ('htmlpure/HTMLPurifier.standalone.php'); $config = HTMLPurifier_Config::createDefault(); $purifier = new HTMLPurifier($config); // purify each description foreach ($_POST['description'] AS $key=>$val) { $_POST['description'][$key] = $purifier->purify($val); }; Quote Link to comment https://forums.phpfreaks.com/topic/268329-using-htmlpurifier-with-foreach/#findComment-1377682 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.