Software, your way.
burger menu icon
WillMaster

WillMasterBlog > JavaScript

FREE! Coding tips, tricks, and treasures.

Possibilities weekly ezine

Get the weekly email website developers read:

 

Your email address

name@example.com
YES! Send Possibilities every week!

Spamming You Through Your Own Forms

Are you getting spammed through your own web page forms?

If not, expect it.

This is what appears to be happening: Spammers' robots are crawling the web looking for forms. When the robot finds a form:

  1. It makes a note of the form field names and types.

  2. It makes a note of the form action= URL, converting it into an absolute URL if neded.

  3. It then sends the information home where a database is updated.

Dedicated software uses the database information to insert the spammer's spew into your form and automatically submit it to you.

Before I present two workable responses to this invasion, let me mention in case you might be tempted to do it, requiring referral information before the form is processed won't work:

  1. People who type your web page into their browser or arrive via a bookmark won't have referral information.

  2. The newest browsers have security/privacy/anti-logging settings that block referrer information.

  3. Some personal firewall software blocks referral information by default.

Blocking those who don't provide referrer information could result in blocking legitimate folks from using your form.

IP address blocking might work temporarily. But if these folks are as sophisticated (which is not very, actually) as those who scan the 'net for forms vulnerable to hijacking, they frequently change IP addresses. The IP addresses these thieves use are likely also used by legitimate surfers.

An Effective Response

An effective response, for the present, is to require JavaScript in order to use the form.

The following will work unless

  • their robots can indeed parse JavaScript or
  • your form information is already in their database (additional solution for that situation is below).

Step 1 —

Copy and paste this JavaScript somewhere below your form (below the closing </form> tag yet above the closing </body> tag).

<noscript>
<!-- Customize this message as appropriate. -->
<h3>JavaScript required to use this form.</h3>
</noscript>
<script type="text/javascript" language="JavaScript">
<!-- Freely obtained from https://www.willmaster.com/
// Between the quotes, put what follows the 
//    action= attribute of your <form... tag:
var url = "/cgi-bin/script.cgi";
// Between the quotes, put what follows the 
//    id= attribute of your <form... tag:
var formid = "myform";
// No other customizations required.
var s = 'document.getElementById("' + formid + '").action = "' + url + '";';
setTimeout('eval(s)',500);
//--></script>

Replace "/cgi-bin/script.cgi" with the value of your <form... tag's action= attribute.

Replace "myform" with the value of your <form... tag's id= attribute. (If your form doesn't have an id, it must be given one. That can be done by putting the id="myform" attribute into your <form... tag.)

Half a second (500 milliseconds) after the JavaScript is loaded into the browser, the form's action= tag will be updated with the specified URL.

Step 2 —

Now, in the <form... tag, replace the value of the action= attribute with "[TURN JAVASCRIPT ON]"

The <form... tag might look something like:

<form
     id="myform"
     action="[TURN JAVASCRIPT ON]">

If a JavaScript-disabled browser is used to submit the form, the "[TURN JAVASCRIPT ON]" message is embedded in the 404 URL.

See the next section if you have already been getting spam through your form or if you start getting it in the future.

If Your Form Information is Already in Their Databases

The only way I know of to counteract the fact that your form information is already in spammers' databases is to change the file name of the form processing program. This will invalidate their data.

Then, also change the above JavaScript accordingly.

In fact, it may be prudent to consider that your form information is already compromised, even if you haven't yet received spam through your form. You might change the file name of your form processing program at the same time you implement the JavaScript.

And that will take care of that.

Will Bontrager

Was this blog post helpful to you?
(anonymous form)

Support This Website

Some of our support is from people like you who see the value of all that's offered for FREE at this website.

"Yes, let me contribute."

Amount (USD):

Tap to Choose
Contribution
Method


All information in WillMaster Blog articles is presented AS-IS.

We only suggest and recommend what we believe is of value. As remuneration for the time and research involved to provide quality links, we generally use affiliate links when we can. Whenever we link to something not our own, you should assume they are affiliate links or that we benefit in some way.

Recent Articles in the Library

Submit Form Data Without Bothering User

To silently and effectively submit a form on a web page, Ajax with FormData() can be used.

CSS Dots

CSS dots can be used for interactions between web page and website user.

Email Testing

One thing to test when email doesn't get sent or doesn't arrive is whether the server actuall sends email.

Tap to Select

Find out how to make a link or button to select the content in a div or other HTML element.

Capitalizing the First Letter of Words

Here, find both PHP code and JavaScript code to capitalize the first letter of a word.

Fixed-position Table Header

During a vertical scroll, the table header scrolls out of view -- unless the header is fixed in position.

Simple Floating Menu

When not needed, the menu on the left side of a web page retracts to be out of the way. Tap it and it expands.

How Can We Help You? balloons
How Can We Help You?
bullet Custom Programming
bullet Ready-Made Software
bullet Technical Support
bullet Possibilities Newsletter
bullet Website "How-To" Info
bullet Useful Information List

© 1998-2001 William and Mari Bontrager
© 2001-2011 Bontrager Connection, LLC
© 2011-2024 Will Bontrager Software LLC