Ex. Form:
field.name forename
field.name surname
field.name company
field.name address, city, state, zip
field.name phone
field.name email
submit
Pseudo:
- Code: Select all
'decs
dim to as string
dim ip as string
dim subj as string
dim msg as string
dim br as string
'defs
to = "user@example.tld.cc"
ip = $_SERVER['REMOTE_ADDR'];
br = chr(13) 'carriage return/linefeed
'parser
for each field in form.objects
if field <> "" then 'skip empty fields
msg = msg & field.name & ": " & field.value & br
if field.name = "forename" or field.name = "surname" or field.name = "company" then 'add to subj
subj = subj & field.value & " "
end if
end if
next field
'add date/timestamp & ip
msg = "RFQ Below received at: " & date & " " & time & "from IP: " & ip & br & br & msg
subj = "PCA RFQ from " & subj
'mail
mail (to, subj, msg)
header ("Location: www.example.com/contact/thankyou.html")
Current:
- Code: Select all
<?PHP
$to = "user@example.tld.cc";
$subj = "";
$date = date ("l, F jS, Y");
$time = date ("h:i A");
$ip = $_SERVER['REMOTE_ADDR'];
$msg = "";
foreach ($_POST as $key => $value) {if (!(empty($value))) {$msg .= $key . ": " . $value . "\n";}}
if (!(empty($msg))) {
$msg = "RFQ Below received at: " . $date . " at " . $time . " from " . $ip . "\n\n" . $msg;
mail ($to, $subj, $msg);
header ("Location: http://www.example.com/contact/thankyou.html");}
?>

