I have built what I think is a nice contact form.
I want to add a cookie to this form so that if a visitor has already completed this form, the browesr recognizes the user and sends them to a page that states they have already filled out this form. It is my understanding that a cookie is the only way to accomplish this and I really do not understand how to use cookies. Shame on me I guess.
Any assistance is greatly appreciated.
<html>
<head>
<title>Contact Form</title>
<script language="JavaScript" type="text/javascript">
function checkForm() {
document.form.Email.value = " " + document.form.Email.value;
if (document.form.FName.value == "") {alert('The First Name field is empty!'); return false; } // script to validate First Name field
if (document.form.LName.value == "") {alert('The Last Name field is empty!'); return false; } // script to validate Last Name field
if (document.form.Address.value == "") {alert('The Address field is empty!'); return false; } // script to validate Address field
if (document.form.City.value == "") {alert('The City field is empty!'); return false; } // script to validate City field
if (document.form.State.selectedIndex == " ") {alert('You have not selected a state!'); return false; } // script to validate State field
if (document.form.Zip.value == "") {alert('The Zip Code field is empty!'); return false; } // script to validate Zipfield
}
// -->
</script>
<script language=”JavaScript” type=”text/javascript”>
document.cookie = "UserName=Paul;expires=Tue, 28 Dec 2020 00:00:00 GMT;path=/;";
</script>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" align="center" width="460">
<tr>
<td style="background-color:red" align="center" colspan="2">
<span style="color:black"><b>Contact Form</b></span>
</font>
</td>
</tr>
<form name="form" method="post" action="success.html"
enctype="text/plain" onSubmit="javascript:return checkForm()";>
<tr>
<td width="170" height="30">First Name:</td>
<td width="290" height="30">
<input size="20" name="FName" style="font-size:9pt" />
</td>
</tr>
<tr>
<td width="170" height="30">Last Name:</td>
<td width="290" height="30">
<input size="20" name="LName" style="font-size:9pt" />
</td>
</tr>
<tr>
<td width="170" height="30">Address:</td>
<td width="290">
<input size="45" name="Address" style="font-size:9pt" />
</td>
</tr>
<tr>
<td width="170" height="30">City:</td>
<td width="290">
<input size="30" name="City" style="font-size:9pt" />
</td>
</tr>
<tr>
<td width="170" height="30">State:</td>
<td>
<select name="State">
<option selected>Choose...</option>
<option>Alabama</option>
<option>Alaska</option>
<option>Arizona</option>
<option>Arkansas</option>
<option>California</option>
<option>Connecticut</option>
<option>Delaware</option>
<option>District of Columbia</option>
<option>Florida</option>
<option>Georgia</option>
<option>Hawaii</option>
<option>Idaho</option>
<option>Illinois</option>
<option>Iowa</option>
<option>Kansas</option>
<option>Kentucky</option>
<option>Louisiana</option>
<option>Maine</option>
<option>Maryland</option>
<option>Massachusetts</option>
<option>Michigan</option>
<option>Minniesota</option>
<option>Mississippi</option>
<option>Missouri</option>
<option>Montana</option>
<option>Nebraska</option>
<option>Nevada</option>
<option>New Hampshire</option>
<option>New Jersey</option>
<option>New Mexico</option>
<option>New York</option>
<option>North Carolina</option>
<option>North Dakota</option>
<option>Ohio</option>
<option>Oklahoma</option>
<option>Oregan</option>
<option>Pennsylvania</option>
<option>Rhode Island</option>
<option>South carolina</option>
<option>South Dakota</option>
<option>Tennessee</option>
<option>Texas</option>
<option>Utah</option>
<option>Vermont</option>
<option>Virginia</option>
<option>Washington</option>
<option>West Virginia</option>
<option>Wisconsin</option>
<option>Wyoming</option>
</select>
</td>
</tr>
<tr>
<td width="170" height="30">Zip Code:</td>
<td width="290">
<input size="30" name="Zip" style="font-size:9pt" />
</td>
</tr>
<tr>
<td width="170" height="30">Email Address:</td>
<td width="290">
<input size="30" name="Email" style="font-size:9pt" />
</td>
</tr>
<tr>
<td width="170" height="30">Phone Number:</td>
<td width="290">
<input size="30" name="Phone" style="font-size:9pt" />
</td>
</tr>
<tr>
<td style="background-color:red" align="center" colspan="2">
</td>
</tr>
<tr>
<td colspan="2" align="center" height="30">
<input type="submit" value="Submit" style="font-size:9pt" />
<input type="reset" value="Reset" style="font-size:9pt" />
</td>
</tr>
</tr>
</form>
</table>
</body>
</html>
Thanks
-T