Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Blocking Pornographic Words

Guest
May 20, 2009 May 20, 2009

Copy link to clipboard

Copied

Hello,

The code below allows the user to add a table to a database, the name of which is chosen by the user.  It works great.  However, I would like to block the user from adding tables with pornographic names like "sex," "porn," etc.  How could I do this?

Thanks in advance,

John

<?php
if (isset($_POST['name']) && !empty($_POST['name'])) {
mysql_connect("mysqlv3", "username", "database") or
die(mysql_error());
mysql_select_db("sand2") or die(mysql_error());

$table = mysql_real_escape_string($_POST['name']);

$query = "CREATE TABLE `$table` (id INT(11) NOT NULL auto_increment, site VARCHAR(150) NOT NULL, votes_up BIGINT(9) NOT NULL, votes_down BIGINT(9) NOT NULL, PRIMARY KEY(id), UNIQUE (site))";
$result = mysql_query($query) or die(mysql_error());


}

?>

TOPICS
Server side applications

Views

528
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
May 20, 2009 May 20, 2009

Copy link to clipboard

Copied

populate your db with table names of unwanted words yourself so user can not create them themselves or use one of the many scripts found via google search term php block words.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 20, 2009 May 20, 2009

Copy link to clipboard

Copied

LATEST

I definitely don't want the terms in my database, either.  I think I'll need to use a script.  Maybe an If statement or something.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines