Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Help with PHP form please!

Featured Replies

Hi,

 

I'm getting spammed quite a bit at the moment, and instead of adding a captcha which I don't really like using, I thought I might use something that blocks certain keywords.

 

I got some free PHP script and have modified it a bit, but don't know how to add more than one keyword to the script. If you click on the link and type in bad, then it will work, but how do I add further keywords to this script?

 

http://www.professionalwebdesigndirectory.com/bad-word-form.php

 

Not to hot on PHP and would be really gratefully for any help!

Pretty difficult without seeing the code. I presume its an array of bad words or something like that?

  • Author

Sorry,

 

<?php

###################################################

####### #####

###################################################

# Declare what word you dont want to allow

$forbiden_word="bad";

 

# if $forbiden_word matches the submited word, clean it

if($_POST['word']==$forbiden_word)

{

$goodword= str_replace($forbiden_word,"",$_POST['word']);

$message='Sorry: <span class="style2"><strong>'.$forbiden_word.'</strong></span> is not allowed!<span class="style2"><strong>'.$_POST[''].'</strong></span><span class="style3"><strong>'.$goodword.'</strong></span>';

}

else

{

$message='<span class="style3"><strong></strong></span>';

}

# If the form has not been sumbited, use the default message

if(!$_POST['word'])

{

$message='';

}

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>Untitled</title>

<style type="text/css">

<!--

.style2 {

color: #FF0000;

font-weight: bold;

}

.style3 {

color: #009900;

font-weight: bold;

}

-->

</style>

</head>

 

<body>

<div align="center">

<p> </p>

<p align="left"> </p>

<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">

<table width="500" border="0" align="center" cellpadding="10" cellspacing="1" bgcolor="#CCCCCC">

<tr align="center" bgcolor="#FFFFFF">

<td colspan="2" nowrap><?php echo $message; ?></td>

</tr>

<tr bgcolor="#FFFFFF">

<td align="right">Location</td>

<td><input type="textfield" name="word"></td>

</tr>

<tr bgcolor="#FFFFFF">

<td> </td>

<td><input type="submit" name="Submit" value="Submit"></td>

</tr>

</table>

</form>

<p align="left"> </p>

</div>

</body>

</html>

$badwords = array("adult", "xxx", "viagra", "phentermine", "tramadol", "adipex", "advai", "alprazolam", "ambien", "ambian", "amoxicillin", "antivert", "blackjack", "backgammon", "texas", "holdem", "poker", "carisoprodol", "ciara", "ciprofloxacin", "debt", "dating", "porn", "link=", "voyeur" , "seminar","SEO","content-type", "bcc:", "cc:", "document.cookie", "onclick", "onload", "javascript","x-x","<a","http","[","href");

foreach ($badwords as $word)
if (strpos($_POST['word'], $word) !== false)
$points += 1;

if ($points>3){
/// Probably a spammer so do something
/// echo a message or redirect to another page
/// anything except let the rest of the script send the email
}

 

Are you sure you would not like a complete ready made email script?

Edited by Sogo7

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.