...I wrote the following simple PHP mail script based on some code Craven sent me a while back:
Code:<?php
//Comma separated emails can allow for sending to multiple recipients.
$to = "[email protected]";
$extra = "From: ".$_POST['email']."\r\nReply-To: ".$_POST['email']."\r\n";
$subject = "Web form submission";
$mess = "This is from: ".$_POST['name']." (".$_SERVER['REMOTE_ADDR'].")\n"
. "\nEmail: " . $_POST['email']
. "\nTel: " . $_POST['tel']
. "\nEtc: " . $_POST['etc'];
mail ($to, $subject, $mess, $extra);
?>
...The specifics of it are not important, but I'm hoping to modify it to work with a long, complex form with dozens of input fields to fill out which may be messed around with regularly.
As such, I'm hoping to not have to write into the mail script all the variables like I'm doing above...
I'm going to make up invalid code here, but this is the kinda thing I'm hoping to do, instead of manually writing all variables & captions into my $mess variable:
Code://THIS SCRIPT CONTAINS BOGUS CODE...Do not try this at home!
$i = 0;
$mess = "";
while ($i <= $_POST.length - 1) {
$mess .= convertVarNameToString($_POST[$i])
. ": "
. $_POST[$i]
. "\n";
$i++;
}
In addition to convertVarNameToString() being bogus, I suspect that $_POST.length won't return the number of items in the array and using $_POST[] with a number as the array item won't work, but hopefully it's a little clearer from that what I'm trying to change ...that is, if I submit data to the script from a form with 2 input objects -- $email with the value "
[email protected]", and $name with the value "Monger" -- my $mess variable should contain the following:
"email:
[email protected]\nname: Monger\n"
Is this (e.g. converting variable names to strings, for starters) even possible? If so, any pointers in the right direction to help me accomplish it would be cool...
Edit: removed autoresponder & validation stuff to shorten code.