PHP: Send email with all form values/fields

if (isset($_POST['Submit'])) {

// Prepare message
$msg "Time: " date("d/m/y g:ia", time()) . "\n";
foreach ($_POST as $field=>$value) {
if ($field != "submit"$msg .= $field ": " $value "\n";
}
if (mail("EMAIL""SUBJECT"$msg"From: FROM_NAME <[email protected]>")) {
// Email was sent successfully
else {
// Error sending email
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *