views:

272

answers:

0

Hi, I have two scripts - javascript and php..

this cleans the url

    <script type="text/javascript">
$(document).ready(function() {
    $('.search-form').submit(function() {
        window.location.href = "/file_"+ $('.search-form input:text').val() + ".html";
     return false;
    });
});
</script>

this is the bad word filter

<?php
    if (isset($_GET['search']))
    {
    $search=$_GET['search'];

    if(is_array($badwords) && sizeof($badwords) >0)
    {
    foreach($badwords as $theword)
    $search = ereg_replace($theword,"haha",$search);
    }
    $search=preg_replace("/\s+/"," ",$search);

    $keyword = str_replace(" ", "+", $search);
    }

    else
    {
    $keyword = str_replace(" ", "+a", $keyword);
    }
    ?> 

how can i combine this two scripts and replace the bad word in the url with "haha"?