How to make two PHP forms in one page work correctly?

Ahmed

New member
I don't know PHP well, but I used to use a PHP code to create forms in web pages, here is the code:
--------------------------------------
<?php
if ($_SERVER['REQUEST_METHOD']=="POST"){
$to="[email protected]";
$subject = ' '.$HTTP_POST_VARS['subject'];
$from = ' '.$HTTP_POST_VARS['email'];
$message = ' '.$HTTP_POST_VARS['message'];
$headers = "From: $from\r\n";
if (@mail($to, $subject, $message, $headers))
echo "Thank you for message..";
else
echo "Error! Try again later..";
} else {
?>
<form method="post" id="form" name="form" enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF']; ?>" onsubmit="return formCheck (this)">
Bla, bla, bla..
</form>
<?php } ?>
--------------------------------------
This code works well when there are one form in a page.
Now I want to make two forms in the same page, I have copied the code, renamed all IDs so that no two fields have the same ID but when I submit a form, the action send a message from the two forms not just the one I have submitted, what can I do to make each form work separately?
 
Back
Top