Answer the question
In order to leave comments, you need to log in
How to make a universal PHP script that will collect all form fields and send them to E-mail?
The script should send to the mail absolutely any number of fields with completely different names. A universal script that will send any form to the mail. As I understand it, you need to take all the name variables from the request, make an array and send it to the mail.
I can't figure out how to write such code.
For example, how to do it on formspree.io - there the input parameter is only E-mail, the rest of the fields are taken from the form of any complexity.
Answer the question
In order to leave comments, you need to log in
<?
$text = '';
if (count($_GET) > 0) {
foreach ($_GET as $key => $value) {
$text .= 'key: ' . $key . ', value: ' . $value . "\r\n";
}
}
if (count($_POST) > 0) {
foreach ($_POST as $key => $value) {
$text .= 'key: ' . $key . ', value: ' . $value . "\r\n";
}
}
// отправка почты
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question