I have 12 forms on the same page each form needs to be able to be submitted on there on. When submitted the info should be emailed to me. I'm looping in PHP to create the forms to the products:
<?php foreach ($_productCollection as $_product): ?>
<form action="" method="post">
<p>
<textarea class="finalTextArea" name="message" id="textarea" placeholder="Motivering MAX 50 Tecken"></textarea>
</p>
<p>
<input type="text" class="finalText" name="name" id="textfield" placeholder="För och Efternamn">
</p>
<p>
<input type="text" class="finalText" name="email" id="textfield2" placeholder="E-mail">
</p>
<p>
<input type="submit" class="finalTextSubmit" name="submit" value="Rösta!">
</p>
</form>
and I'm trying to email the form to me using this code:
<?php
if(isset($_POST['submit'])){
$to = "martin@imonline.se"; // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
$first_name = $_POST['name'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message = $first_name . " " . " wrote the following:" . "
". $_POST['message'];
$message2 = "Here is a copy of your message " . $first_name . "
" . $_POST['message'];
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
echo "Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
}
?>
It works on the first form, and when that's submitted it won't work at all. Is there a way to do this with AJAX or another solution ?