Form Processing Problem

Hi,

I’m encountering a problem with a contact form script, despite using a very standard approach that I have used many times before:


if ($_SERVER['REQUEST_METHOD']=="POST") {
//process for errors in the submitted form and show the form again with prompts
}
else {
//show the form for the first time
}
}

However, even when the form is shown for the first time, it is showing with error messages for empty fields etc. Even with nothing in the function other than an echo for the request method, I get POST

There are other forms on the same page (for searching and registration), which may be causing the problem. Wandered if anyone had suggestions for the best way to add an extra control so that my contact form displays correctly?

Many thanks in advance

Please ignore - have switched on my brain and added a session variable to get the additional control as per the following:


function ShowContactForm() {
if ($_SERVER['REQUEST_METHOD']=="POST" && $_SESSION['contact_form_submitted']=="yes") {
echo "Show the form with errors";
}
else {
echo "Show the form for the first time";
$_SESSION['contact_form_submitted']="yes";
}

}