FAQ: How can I send my visitor to another page after they submit my form?

A: That depends. If you are using a CGI script to process your forms (preferred) then that capability is probably there. The directions for using that particular script may have you send the redirect URL as a hidden field, or it may be specified in the CGI script itself. Either way, consult the documentation for that script.

If you are using mailto forms then there's still something we can do. Understand however that mailto forms can be unreliable depending on the visitor's browser/email setup. Some visitors may have trouble sending the data. (How many? 5%? 20%? More? I don't know.)

Also, the mailto redirect requires Javascript, and while most people have javascript enabled, those that don't won't get redirected. So, all warnings given... here's how to add a javascript redirect to a mailto form:

First add this in the HEAD section of your document...

<SCRIPT language="JavaScript"><!--
function FormRedirect(){
setTimeout('this.document.location.href = "page.html"',5000);}
//--></SCRIPT>

Where page.html is the URL of the redirect document.

Then add this to your FORM tag...

onSubmit="FormRedirect()"

Below is a sample form.

<FORM NAME="myform" METHOD=POST ACTION="mailto:abc@123.org"
      ENCTYPE="text/plain" onSubmit="FormRedirect()">
<INPUT TYPE="text" NAME="mytextbox" VALUE="">
<INPUT TYPE="submit">
</FORM>

Note the 5000 in the function. It is a 5000 millisecond delay (5 seconds) and it's necessary to allow the browser to actually send the data before the redirect occurs. If the browser takes longer than 5 seconds, it redirects anyway and the data goes bye-bye. If the mailto action fails, the redirect happens anyway and the data again goes bye-bye. (Actually, the data is probably going to still be there if the user hits the back button. But, unless he makes other efforts to send it to you, you'll never see it.)

Unfortunately a setup like this isn't the wisest thing in the world. In most instances it will work as planned, but it's sort of house of cards. A house of cards looks neat, but it doesn't take much to knock it down. Your form put together this way will be cool alright, but it wouldn't take much to make it take a dump.


One more little tidbit and we're going to wrap this up. When you put a mailto form on your page and someone sends you information, you'll notice that it is sent with a default Subject. If you're visitor was using Netscape you'd get the default Subject "Form posted from Mozilla". Other browsers might send "Form Response", etc.

You can change this by editing what's in the <FORM> tag as follows...

<FORM METHOD=POST ACTION="mailto:robin@batman.org?subject=Jumpin Jellyfish!" ENCTYPE="text/plain">

Pretty cool huh?

Be advised however, that floating around out there are a few old email clients that can't handle a subject specified in that manner. In that situation, the data might appear to be sent, but in reality, it just dissappears into oblivion. If an occasional lost response is a concern to you, don't specify a subject.

If you skipped the part in the beginning that talked about CGI Form Handlers, I want you to go back and become familiar with the process. As I've said before, mailto forms can be a little troublesome and/or unreliable for a certain percentage of your visitors. If you are concerned about these potential problems, you should really use a form mail script.

<< BACK         NEXT >>