Im trying to use PHP Mail function to send myself an email of all post variables.
So far I have this...
$message = foreach ($_POST as $key => $value)
echo "Field ".htmlspecialchars($key)." is ".htmlspecialchars($value)."<br>";
$message = wordwrap($message, 70);
mail('[email protected]', 'sghting', $message);
Only the message being submitted is my last post record, can anybody see where im going wrong?
foreach ($_POST as $key => $value)
$message .= "Field ".htmlspecialchars($key)." is ".htmlspecialchars($value)."<br>";
mail('[email protected]', 'sghting', $message);
$message = foreach ($_POST as $key => $value)
is not correct, this will iterate over the results and store the last one. You want to store the values in your $message variable, not echo them.
$message = "";
foreach ($_POST as $key => $value)
$message .= "Field ".htmlspecialchars($key)." is ".htmlspecialchars($value)."<br>";
mail('[email protected]', 'sghting', $message);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With