Hello all,
This pertains to a form I have on my page.
As it is now, if the person filling out the form makes a mistake or leaves something out, the form reloads, but all the prior responses are wiped out.
I can see how this might annoy someone, to have to fill everything out all over again, even if they neglected to fill in just one field.
What I would like is to have the error noted (as it is now) but to reload the values the visitor posted before hitting "Submit".
I assume the way to do this is via session cookies (the kind that only last while the browser is open).
I must have looked at about 50 different sites on the net, but I could not find a simple explanation. Most go off on some complex application of setting cookies, far beyond what I am looking for.
Basically, all I am looking for is:
A) A way to set the above cookie
and
B) Where to place it
it would be nice to have:
C) The cookie is destroyed upon SUCCESSFUL completion of the form.
Can anyone please help?
Below is my code:
<?
$RandomStr = md5(microtime());
$Str = substr($RandomStr,0,5);
if($_GET['error'] == "empty")
{
$msg = "Please fill all form fields.";
}
elseif($_GET['error'] == "name")
{
$msg = "Please fill in your name.";
}
elseif($_GET['error'] == "email")
{
$msg = "Please provide valid email address.";
}
elseif($_GET['error'] == "phone")
{
$msg = "Please provide your daytime phone number.";
}
elseif($_GET['error'] == "event_title")
{
$msg = "Please provide the title of the event.";
}
elseif($_GET['error'] == "event_date_and_time")
{
$msg = "Please provide the date and time of the event.";
}
elseif($_GET['error'] == "event_location")
{
$msg = "Please provide the location of the event.";
}
elseif($_GET['error'] == "event_phone_number")
{
$msg = "Please provide a phone number for the venue.";
}
elseif($_GET['error'] == "event_price")
{
$msg = "Please provide a price to attend the event.";
}
elseif($_GET['error'] == "event_description")
{
$msg = "Please provide a description for the event.";
}
elseif($_GET['error'] == "spam")
{
$msg = "Please enter correct turing code.";
}
elseif($_GET['msg'] == "success") {
$msg = "We have received your feedback and will get back with you as soon as possible, if required.";
}
else {
$msg='';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Clubs Submission Form</title>
</head>
<body>
<p style="color:#ff0000;font-weight:600;"><?=$msg?></p>
<form name="Contact" action="SendMail.php" method=post>
<!--<input name="recipient" type="hidden" value="clubsub@metronews.com">-->
<!--<input name="subject" type="hidden" value="Clubs submission from Metroactive.com">-->
<!--<input name="redirect" type="hidden" value="http://www.metroactive.com/contact/thanks.html">-->
<p>Your Name:</p>
<input type=text name="name" class="class_form_field">
<p>Your E-mail Address:</p>
<input type=text name="uemail" class="class_form_field">
<p>Your Daytime Phone:</p>
<input type=text name="phone" class="class_form_field">
<br><br>
<p>Club Event Title:</p>
<input type=text name="event_title" class="class_form_field">
<br><br>
<p>Date and Time:</p>
<input type=text name="event_date_and_time" class="class_form_field">
<br><br>
<p>Location:</p>
<input type=text name="event_location" class="class_form_field">
<br><br>
<p>Phone Number:</p>
<input type=text name="event_phone_number" class="class_form_field">
<br><br>
<p>Price:</p>
<input type=text name="event_price" class="class_form_field">
<br><br>
<p>Event Description:</p>
<textarea class="class_form_field" rows=20 wrap=virtual name="event_description"></textarea>
<p>Enter Security Code:</p>
<p style="background-image:url(images/anit-spam.gif);width:150px;height:50px;"><b><?=$Str?></b> </p><input type="text" size="8" name="code">
<input type="hidden" size="8" name="hcode" value="<?=$Str?>">
<br /><br />
<input type=submit value="Submit Contact Form">
<input type=reset value="Clear Form" size="20">
</form>
</body>
</html>