May 15, 2008

Php Word Filter - Have you accidently sworn on your site? Or do you want to keep visitor

Free Web Hosting, No Ads > CONTRIBUTE > Tutorials

free web hosting

Php Word Filter - Have you accidently sworn on your site? Or do you want to keep visitor

KansukeKojima
This is pretty simple but very useful if you don't want people to swear. We will be using str_replace for this.

CODE
<?php
str_replace ("curseword, "replacemet");
?>


Thats pretty simple, just fill in the curse word and the replacement, and then repeat... heres what it would look like full size:
CODE
<?php
str_replace("swear", "replacement");
str_replace("swear", "replacement");
str_replace("swear", "replacement");
str_replace("swear", "replacement");
?>


Ok, but how do you get it to work on your page now? Well, save that file as wordfilter.php and use
CODE
<?php include "wordfilter.php"; ?>
at the top of your page... and now people can't swear...

By the way, I'm pretty sure these are case sensitive, so you'll have to put capitals as well, etc..

 

 

 


Reply

truefusion
Although the str_replace function is one way to filter out certain words from strings, the example you provided would not work if actually used on a site for the following reason: subject parameter is not set. I'm quite sure PHP would output an error similar to that if tested. For case insensitivity, you could use str_ireplace.

Reply

coolcat50
This will not work at all. There is no origin of content to replace from and no variable to actually echo. This would be more correct. This will be a chatbox example.

CODE
<?php
$shout=strip_tags($_POST['shout']);

$shouts=str_replace("curse","replace",$shouts);
//Repeat each word

//mysql query
?>


That would be the correct form. Your example will simply provide an error. If it were to work it would still display the curse word due to no variable being stored.

Reply

KansukeKojima
I guess so eh....... to do this really fast, you could do what I said in the "Nice clean php coding" thread, then you could just strip from the $template variable, and when you echo it, the swears, and whatever are gone.....

Reply

RandomThoughts
QUOTE(coolcat50 @ Nov 21 2007, 02:09 AM) *
This will not work at all. There is no origin of content to replace from and no variable to actually echo. This would be more correct. This will be a chatbox example.

CODE
<?php
$shout=strip_tags($_POST['shout']);

$shouts=str_replace("curse","replace",$shouts);
//Repeat each word

//mysql query
?>


That would be the correct form. Your example will simply provide an error. If it were to work it would still display the curse word due to no variable being stored.


I think the $shout variable should be $shout and not $shouts as the parameter to the str_replace function.

 

 

 


Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Recent Queries:-
  1. word filter php - 1245.63 hr back.
  2. cache:xyswfwy-srej:www.trap17.com/index.php/php-menu-bulding-script-site-template_t34124.html download, swear replacement - 1258.96 hr back.
Similar Topics

Keywords : php, word, filter, accidently, sworn, site, visitor

  1. Simple Stylesheet Tutorial
    Stylesheet embedded in your site. (2)
  2. How To Set Up A Bookmarking System On Wii
    Use your favorite social bookmarking site. (0)
    This is a simple tutorial on a way to set up a bookmarking system on your Wii with greater stroage
    than the Favorites. It is more complicated than the Favorites and requires manual URL typing. Well
    let's dive on in. Items Required Nintendo Wii Internet Channel 3 Empty Favorites Internet
    Connection An account on a social bookmarking site I will be using delicious as an example.
    delicious Ok, if you do not have an account, read on. If you do have an account, go to the
    {account} section. Ok, first you need to register an account. This can be done by clicki....
  3. Create A Google Seach Result Page Embed Within Your Site Page.
    (11)
    Create a google seach result page embed within your site page. It is easier to create
    web page that embeded the google search result in it. The first step is to go to google apply an
    account for the google ad-sense. After that login to you account and choose the create ad-seach
    option. Most of time the google search box give all we have the great and powerfull seach ability.
    But, have you think every time users get seach with it. They do redirected to another page that is
    not within you site. It is easier to create web page that embeded the google sea....
  4. Faux Ajax Loading - Css Only
    Pretend your site is Ajax based (3)
    Link: http://www.jlhaslip.trap17.com/samples/misc/ajax/index.html Check that out. The first page
    has information and the second and has the actual example of its use with sample CSS code. I find
    that when you visit a site which has a slow server and attempt to view 'large' Image files,
    it is pretty boring to sit and stare at a blank screen, so this little snippet of code can be used
    to give the visitor something to see to indicate that the image is being downloaded. I built a
    small animated gif that sits in the background of the space allocated for the image....
  5. Making The Popular Id Browsing For Your Site.
    (17)
    Was just sitting and being bored but then I realized I could show how to create more or less popular
    ?id=page browsing. It's actually really easy. I know two ways how to do it. First one I learned
    was checking the variable and if it's true including the text/file/anything needed and so on. It
    was ok, but sometimes I just couldn't make it work so I switched to switch() function and
    that's what I'm going to show you guys right now. So, I made a test page which contains the
    code needed and here is its source. CODE <!DOCTYPE HTML PUBLIC ....
  6. Cpanel Useful Site Management Tools 2.1
    Part 3 of My 7 Part Tutorial (0)
    This Tutorial will be divided into 7 different parts, and this is the first part, when i get the
    other parts together, i will post the links under here /biggrin.gif" style="vertical-align:middle"
    emoid=":D" border="0" alt="biggrin.gif" /> Enjoy. Part 1: E-mail Management Part 2: Useful Site
    Management Tools Part 4: Analysis/Log Files Part 5: Advanced Tools Part 6: PreInstalled
    Scripts, Extras, and Cpanel Options Part 7: Fantastico Detailed Cpanel Tutorial Part 2.1:
    Useful Site Management Tools In this tutorial I will, in detail explain all of th....
  7. Cpanel Useful Site Management Tools
    Part 2 of My 7 Part Tutorial (0)
    This Tutorial will be divided into 7 different parts, and this is the first part, when i get the
    other parts together, i will post the links under here /biggrin.gif" style="vertical-align:middle"
    emoid=":D" border="0" alt="biggrin.gif" /> Enjoy. Part 1: E-mail Management Part 3: Useful Site
    Management Tools2.1 Part 4: Analysis/Log Files Part 5: Advanced Tools Part 6: PreInstalled
    Scripts, Extras, and Cpanel Options Part 7: Fantastico Detailed Cpanel Tutorial Part 2:
    Useful Site Management Tools In this tutorial I will, in detail explain all of t....
  8. Templating System Using Php Includes
    Building a Dynamic site using Includes and flat-files. (13)
    Php based Templating System http://jlhaslip.trap17.com/template/index.php The Source Code
    for the scripts are included (literally) on the different pages on the Demo, including the Contact /
    Email script. The only page not there yet is the Message Script. Maybe tonight I will upload that.
    This one uses a little bit of query-string checking to confirm that the contents of the page are
    actually available (file_exists())and an allowed page content before serving it up. The
    'allowed page content' is done by checking against a flat-file containing an array....
  9. Php Menu Bulding Script And Site Template
    available for download (0)
    A Php Menu-builder Tutorial This Sidebar Menu-builder code and the php scripts are adapted from
    a Tutorial on the Astahost.com Forum titled : CMS101 - Content Management System Design .
    Since the original tutorial's author (vujsa) did such a marvellous job of describing the system
    in the original Topic posting, I will not attempt to explain it here, rather, I invite you to have a
    look at his Topic and learn from it. The Basic tutorial provided coding for developing a table-based
    web-site template which used php includes and embedded data to create a &....
  10. Php Spy Code
    Spy on your site! (21)
    Code Spy Code Description Anyone who comes to ur forum's IP Adress, Site they came From,
    Their Browser and the time they came will get saved in a place that only the admin knows the
    location of... V.2 More features coming up in V.2!!! POst suggestions/problems...
    Preview:- http://s15.invisionfree.com/Spy/index.php ? REFRESH THE PAGE, AND GO HERE:-
    http://h1.ripway.com/programming/spy%20code/spy.html ^^^^^^^That shows all the IP's, Browsers,
    Time, site and stuff....^^^^^^^^ Code First of all, you'll need to host the files.... I sugg....
  11. How To: Make A Simple Php Site
    Making one file show up on all pages using php (20)
    I have looked all over the site and could not find anything that was like this simple, or just like
    this at all.. For some people i know that you are using a basic HTML site...and having a big menu
    if you want to add somthing you have to go into every one of the pages and add or remove or edit
    what you want to do, but with somthing verry simple all you would have to do is edit one file, and
    all of the pages that have the PHP script on them would suddenly change to what that one file is.
    So to start off if you are planning on using this little tirck, the page that you a....
  12. Not To Be Banned By Google
    Take care that your site is not banned (2)
    /sad.gif' border='0' style='vertical-align:middle' alt='sad.gif' /> Strategic search engine
    optimization involves far more than keyword research, META tags and content. If you want to mange an
    SEO program, you need to be aware of any issue that can affect your success. Domain name management
    is one of the big factors. Effective domain name management is critical because you could end up
    getting banned from Google and other search engines if you take the wrong approach. Why would
    Google ban you? In the spirit of fair play and providing depth in its results, Google ....
  13. Set Os X Server 10.3 Dhcp To Filter Desks
    Restrict which PCs/Macs get DHCP IP #s (0)
    Among my other duties, I help run a small computing lab for med students at the U of MN. Recently I
    learned that though we only have about twenty legitimate DHCP clients on our wired ethernet getting
    addresses from our Mac OS X 10.3 Server (great system), thirty allocated DHCP addresses were being
    used. Huh? I found that some addresses went to testing, which I understand, but others were being
    grabbed by PCs that should have static IPs but were misconfigured and/or by outsiders who unplugged
    our PCs to network personal laptops (a no-no). We don't watch our PCs all t....
  14. Phpbb Forum Site Transfer
    How to do it, step by step instructions (20)
    I'm sure many of you out there have used phpBB at some point. To those who enjoy running forums
    and online communities, specifically supporting phpBB, I am about to tell everyone how to restore
    the forums database from one website, to another. This is presuming you do not have any mods or
    hacks installed. Some of you may find this information useful. Here is the scenario: Let's say
    you have forums running phpBB version 2.0.17 (currently the latest one). You have decided that you
    want to move your forums to a whole new URL and provider, and as an added bonus, ch....
  15. Css And Javascript Combined For Dynamic Layout
    use of different CSS files at same site (8)
    This tutorial is meant for people that are dealing with problems while coding their site at 100% of
    width. Important notice: Some people has JavaScript disabled, so they will not be able to load CSS
    file (take this in account when creating your website). How this script works. In the HEAD of your
    HTML document will apply this command, so variable.js file will be load at start: CODE
    <script type="text/javascript" src="variable.js"></script> In
    browser JavaScript file variable.js is loaded. This Javascript file consist of this para....
  16. How To Make A Very Simple Wap Site
    A quick tutorial about WML language (40)
    WAP Site Tutorial : How to Make A Wap site? Before We begin.. Defination from the
    Web about Wap. QUOTE WAP is an open international standard for applications that use
    wireless communication . Its principal application is to enable access to the Internet from a
    mobile phone or PDA .A WAP browser provides all of the basic services of a computer based web
    browser but simplified to operate within the restrictions of a mobile phone. WAP is now the
    protocol used for the majority of the world's mobile internet sites, known as WAP sites ....
  17. A Php Loginscript For Your Site
    For everybody (19)
    Many people want to make logins to their site. The easiest way to do this is using PHP. I will
    describe here all steps creating one. You can copy and paste the code and save it as the name of the
    file given above the code. Save everything in the same directory. NOTE: However the code can be
    copied its still no basic php anymore. If you have questions you can ask them but a little knowledge
    of php is useful. First of all we need to make a login form. This can be an htmlpage. We are
    going to ask the user for his username and his password. File is named: "login.html....
  18. How To Upgrade Your Nuked Site
    a simple how to (1)
    this can be found on my site. QUOTE Ok, so let's upgrade your nuked site. Make a temporary
    page saying that you're upgrading, or if you have nuke sentenel, disable your site. Pick a good
    version that is secure and stable. Use this link:
    http://www.nukescripts.net/modules.php?nam...wnloads&cid=300 ok, so now just upload everything, I
    suggest via FTP. You can just select all the files in the root directory and drag them into the root
    directory on your site. All the needed files must be overwriten. Now it's time to patch the
    site. Download the latest p....
  19. How To Make Your Site Sticky
    How to make your site more atractable (9)
    These are some basic ways in which you can make your site sticky. QUOTE What is sticky? A
    sticky website is one that a visitor will keep coming back to, expecting to find out if there has
    been an update. It is the fascination of the visitor that this site is constantly changing that
    draws them near. Here are the useful tips. How much text-imagery should I have on my site?
    Generally it should be 70% text or space and 30% imagery. Remember that the site layout (table
    borders, backgrounds, etc) count as 10% in total (no matter how much or little) of imagery. 1....
  20. Checking The Web Site Speed
    (10)
    Did you taking too much time to access your favorite sites? Probably the problem is on the server
    used by those sites. To make sure that is the problem, use Windows PING facility. Ping is a small
    program, which sends a 32-bit signal to the Web site server. Next, Ping record the time needed by
    the server to answer it. To activate Ping: Click on the Start-Run menus, type command, and then
    click OK. Type PING "site name" in the MS-DOS prompt window, for example PING www.yahoo.com. In a
    moment, the result will appear on the screen. A result less than 300ms is normal spee....
  21. How To Put A Phpbb Login Box On Your Main Site.
    Code and .php included!!! (17)
    I have included my coded file with this... Ok here is the code. CODE // //Create login area,
    replace the phpBB2 in /phpBB2/login.php with your forum's //directory // <form
    action="/phpBB2/login.php" method="post" target="_top"> <table
    width="25%" cellspacing="2" cellpadding="2" border="0"
    align="center">  <tr> <td align="left"
    class="nav"><a href="/phpBB2/index.php" class="nav">Prank Place
    Forum Index</a></td>....
  22. Excluding Your Site From Showing Up On Search Engines
    Or how to prevent stalkers from finding your personal site. (0)
    Firstly, I suppose there are very few people here who would want to do this. Most people want
    their sites to be listed on search engines, and these are probably the ones thinking that I must
    have a loose screw or something. But if you use your site for personal blogging and want to keep it
    open to friends and yet prevent your privacy from being infringed upon, this is worth looking at.
    What you need: 1. A text editor. Notepad works fine for me. 2. Coffee. (Not because you're going
    to stay up all night, but because I like to drink coffee for any and every reason po....
  23. How To Setup A Php-nuke Based Site
    very helpfull (5)
    Ok, so you want to have a php nuke site. First of all, what is this "PHP nuke", and why is it so
    special? Php nuke is a web portal system. It is expandible, and can be very usefull. You can find
    an example here. Yes, it is that good. So, lets take a closer look. It's pre-packaged basic
    features are: *forums *a login system *weblinks *downloads *news *polls *faqs *content You can
    allways de-actuvate some features, but it's near-imposible to remove them. Kinda annoying, but
    you know. Some people may not need phpnuke, or cant have i period. You need: *some ....
  24. Who's Viewing My Site?
    Targeted for AIM users (11)
    As some of you may know, I asked a question on how to get a portion of the URL in the address bar
    and save it, and thanks to several sources*, I have successfully learned how to do that. Today, I
    will share with you, step-by-step, my knowledge. The object of this tutorial is to mimic a
    feature on many subprofiles where you're able to see the AIM screennames of people who viewed
    your site. Note : The URL that I will be using extensively throughout this tutorial is
    http://yoursite.trap17.com . This is not a special URL reserved on trap17 but is merely a represe....
  25. HTML tags and examples
    Condensed form of course from my site... (37)
    Well, I decided to try and help out some of the users here who might be unexperienced in HTML, so I
    condensed the begginer's HTML course at my website. Here it is... Lesson 1 HTML means Hyper
    Text Markup Language. HTML is a very common language used for many websites, is the base for more
    complicated and powerful langauges like php, HTML can seem hard, but you will find it is one of the
    easiest langauges one can learn. The core of HTML is the tag, a tage is just a set of two
    arrows-like brackets created by hitting Shift and the comma key, or Shift and the period....
  26. Php Quiz Script
    Make quizzes for your site. (15)
    Hello all, A little bit back I decided to make a quiz scriptjust out of no where lol. However it
    doesnt do anything special but I am going to make an email mod for it so that it will email results
    to your email address. So here is the basis of it. INSTRUCTIONS: Open a new page in your text
    editor and paste in the following code. CODE <?php $qid = "Quiz ID-00"; ?>
    <html> <head> <title><? echo "Gamers Pub $qid";
    ?></title> </head> <body> <p><h3><? echo "....
  27. How To Host Ur Own Site In 2 Mins Php+mysql Needed
    (34)
    QUOTE Run you're own server for testing phpmysql or just to host you're own website or
    for you're friends. -needS: a PC that's all 8) - How to ? download : CODE
    http://server.paehl.de/apache20.zip : 30 seconds Installing:---> 1 minute
    *********************************** Unpack the exe where ever you want. after unpack run
    serverinst.exe and change Servername and your e-mail. Start the following files one time:
    start_apache.cmd --> start apache as service mysql_start_as_service.cmd  --> dito for mysql
    mysql_first_st....
  28. Php Emailer/contact System
    An email or contact system for your site (20)
    Hello all, Here is an easy Emailer or Contact system that allows visitors or members of your site
    to email you just by filling out a form. So here is what you need to do to set it up. First open up
    a new page in your text editor and paste in the following code. CODE <?php $Name =
    $_POST['Name']; $Subject = $_POST['Subject'];
    $Email = $_POST['Email']; $Site =
    $_POST['Site']; $Message=$_POST['Message'];
    $align = $_POST[&#....
  29. [tutorial] Skinning Your Site
    a tutorial on how to skin your website (2)
    For this tutorial you are going to need to know how to use php includes. You are also going to need
    to rename all o your files to a .php extension. In your FTP or Cpanel make a folder in your public
    (main) directory and name it "skins". In the skins folder make another folder named "1". In the
    folder you names skins make a file called cookiecheck.php. Copy the code below and paste it into the
    cookiecheck.php file. $total_skins = 1; $default_skin = 1; if (isset($_REQUEST
    )) { $newskin=(int)$_REQUEST ; if ( ($newskin $t....
  30. Site Icon Tutorial
    (5)
    You've probably all seen that Trap17 and many other sites have a small icon that gets displayed
    in the address bar, or in your favourites/bookmarks. Well, here's how to get an icon on your own
    site: 1. Choose either 1A or 1B 1A: You can either make an icon yourself with your favourite icon
    making program 1B: Make a square picture, any size you want and save it. When you're done making
    the picture, go to this site , upload the image and download the zip. Then unpack the zip to get
    the icon. 2. Great! Now you have an icon. If it's not called favicon.....

    1. Looking for php, word, filter, accidently, sworn, site, visitor

Searching Video's for php, word, filter, accidently, sworn, site, visitor
Similar
Simple
Stylesheet
Tutorial -
Stylesheet
embedded in
your site.
How To Set
Up A
Bookmarking
System On
Wii - Use
your
favorite
social
bookmarking
site.
Create A
Google Seach
Result Page
Embed Within
Your Site
Page.
Faux Ajax
Loading -
Css Only -
Pretend your
site is Ajax
based
Making The
Popular Id
Browsing For
Your Site.
Cpanel
Useful Site
Management
Tools 2.1 -
Part 3 of My
7 Part
Tutorial
Cpanel
Useful Site
Management
Tools - Part
2 of My 7
Part
Tutorial
Templating
System Using
Php Includes
- Building a
Dynamic site
using
Includes and
flat-files.
Php Menu
Bulding
Script And
Site
Template -
available
for download
Php Spy Code
- Spy on
your
site!
How To: Make
A Simple Php
Site -
Making one
file show up
on all pages
using php
Not To Be
Banned By
Google -
Take care
that your
site is not
banned
Set Os X
Server 10.3
Dhcp To
Filter Desks
- Restrict
which
PCs/Macs get
DHCP IP #s
Phpbb Forum
Site
Transfer -
How to do
it, step by
step
instructions
Css And
Javascript
Combined For
Dynamic
Layout - use
of different
CSS files at
same site
How To Make
A Very
Simple Wap
Site - A
quick
tutorial
about WML
language
A Php
Loginscript
For Your
Site - For
everybody
How To
Upgrade Your
Nuked Site -
a simple how
to
How To Make
Your Site
Sticky - How
to make your
site more
atractable
Checking The
Web Site
Speed
How To Put A
Phpbb Login
Box On Your
Main Site. -
Code and
.php
included!
;!!
Excluding
Your Site
From Showing
Up On Search
Engines - Or
how to
prevent
stalkers
from finding
your
personal
site.
How To Setup
A Php-nuke
Based Site -
very
helpfull
Who's
Viewing My
Site? -
Targeted for
AIM users
HTML tags
and examples
- Condensed
form of
course from
my site...
Php Quiz
Script -
Make quizzes
for your
site.
How To Host
Ur Own Site
In 2 Mins
Php+mysql
Needed
Php
Emailer/cont
act System -
An email or
contact
system for
your site
[tutorial]
Skinning
Your Site -
a tutorial
on how to
skin your
website
Site Icon
Tutorial
advertisement



Php Word Filter - Have you accidently sworn on your site? Or do you want to keep visitor



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE