NateMail Question

NateMail, ProcessForm, JavaScript Form Validator, Form Security, etc.
Posts: 1
Joined: 01/14/2006 @ 15:39

NateMail Question

Postby mockass » 01/14/2006 @ 15:48

I just updated my script to allow users from several addresses to receive mail, however, the HTML I'm using is causing a slight problem. In using the following dropdown...

<select name="recipient" id="BandMember">
<option selected>Please Select</option>
<option value = 0>The Band</option>
<option value = 1>Billy</option>
<option value = 2>Danny</option>
<option value = 3>Chai</option>
<option value = 4>Brandy</option>
<option value = 5>Brad</option>
<option value = 6>Steve</option>

...messages get to the proper person, however, when I previously had the select name value set to "BandMember", the e-mail received had information from the actual dropdown menu. For example, it would say Band Member: Billy. Since changing select name to "recipient", it doesn't include this info, can you think of a way to get around this?


Nate Baldwin
Site Admin
Posts: 3724
Joined: 04/25/2003 @ 19:05

Postby Nate Baldwin » 01/15/2006 @ 21:09

Sure, you can just make a small modification in the script to have the recipient value also populate the name of the person it was sent to. So, at the top of the script after the opening <?php tag, add a new line and past in this PHP code...

Code: Select all

$recipient_names = array();
$recipient_names[0] = "The Band";
$recipient_names[1] = "Billy";
$recipient_names[2] = "Danny";
$recipient_names[3] = "Chai";
$recipient_names[4] = "Brandy";
$recipient_names[5] = "Brad";
$recipient_names[6] = "Steve";
// add as many extra lines as you need, synced with $recipients list

$sent_to = (isset($_POST['recipient'])) ? $_POST['recipient']+0 : -1;
if ($sent_to > -1 AND isset($recipient_names[$sent_to])) {
$_POST['sent_to'] = $recipient_names[$sent_to];
$HTTP_POST_VARS = $_POST['sent_to'];

Basically, enter the names in that list at the top to match up with the recipients in your $recipients list (and add as many as you need). Then the script will use the recipient number to add a new field named "sent_to" with the value being the person's name.

If something doesn't work right, please post back. Haven't tested anything, just wrote it on the fly.

Return to “Form Processing (NateMail, ProcessForm)”

Who is online

Users browsing this forum: Google [Bot] and 1 guest