|
Posted by Janwillem Borleffs on 11/26/05 00:50
mo wrote:
> I'd like to use this form to send a seperate email message to (depend
> on the city, which has a different email address) NY and LA...
> how to do this in php?
>
First, you get rid of the mailto form action by replacing it with the
following:
<form action="<?php print $_SERVER['PHP_SELF'] ?>" method="post">
And then, you prepend a script like the following (that is, *before* the
HTML):
<?php
$sender = 'You <you@yourdomain.com>';
$recepients = array(
'wybierz' => 'emaila@mail.com',
'ny' => 'emailb@mail.com',
'la' => 'emailc@mail.com'
);
if (isset($_POST['wyboor']) && isset($recepients[$_POST['wyboor'])) {
$recepient = $recepients[$_POST['wyboor']];
$username = $_POST['username'];
$subject = "A mail from $username";
$msg = 'A message from $username";
if (mail($recepient, $subject, $msg, "From: $sender")) {
print "Message from $username sent to $recepient";
}
}
?>
JW
Navigation:
[Reply to this message]
|