Answer the question
In order to leave comments, you need to log in
How to auto collect data from all fields from the form in mail.php and send via phpmailer?
There are 2 forms that have a different number of fields, but also have the same inputs by name.
Sending is implemented through a script and using phpmailer:
$(document).ready(function() {
//E-mail Ajax Send
$("form").submit(function a() { //Change
var th = $(this );
$.ajax({
type: "POST",
url: "core/components/mail.php", //Change
data: th.serialize()
}).done(function() {
setTimeout(function() {
// Done Functions
th.trigger("reset");
}, 1000);
});
return false;
});
});
The data is pulled out from the fields and pushed into the starting table, this is 1 form
$number = $_POST['NumberOfOperators'];
$name = $_POST['Name'];
$namecom = $_POST['NameCompany'];
$phone = $_POST['Phone'];
$email = $_POST['Email'];
$html = "
Number of managers (operators): | {$_POST['NumberOfOperators']} |
Name : | {$_POST['Name']} |
Name of the company : | {$_POST['NameCompany']} |
Telephone : | {$_POST['Phone']} |
Email : | {$_POST['Email']} |
Name : | {$_POST['Name']} |
Telephone : | {$_POST['Phone']} |
Email : | {$_POST['Email']} |
Message : | {$_POST['Message']} |
Answer the question
In order to leave comments, you need to log in
$phone = filter_var($_POST['phone'], FILTER_SANITIZE_STRING);
.....
if($name){ $message = "<b>Имя:</b> ".$name."<br>"; }
if($phone){ $message .= "<b>Телефон:</b> ".$phone."<br>"; }
if($email){ $message .= "<b>e-mail:</b> ".$email."<br>"; }
.....
mail($to, $subject, $message, $headers);......
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question