Forum Moderators: coopster & phranque

Message Too Old, No Replies

passing contents of input field to the subject line in FormMail

FormMail.pl question

         

Aquaholic

5:21 pm on Sep 10, 2002 (gmt 0)

10+ Year Member


I need to know if I can take the inpute data that is provided in the below field "AR Number" and have it not only be added to the body of the message but also append to the subject line.

html form:

<table border =3>
<BR>
<td align="center">&nbsp;&nbsp;
AR Number:<FONT COLOR="#C40000">*</FONT>
<input name="AR Number" type="text" size="9" maxlength="9">

<input type="hidden" name="subject" value="AR Update">

output of the email as it is right now with customer submitting 1234 in the "AR Number" fieled with a fixed subject of AR Update:

From: Happy Gilmore
Sent: Tuesday, September 10, 2002 9:18 AM
To: Gilmore@happyplace.com
Cc:
Subject: AR Update
_______________________________________

AR Number: 111

jatar_k

6:04 pm on Sep 10, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld [webmasterworld.com] Aquaholic,

If you take a look at the mail function [php.net], you can see that the function uses this format in the call.

bool mail ( string to, string subject, string message [, string additional_headers [, string additional_parameters]])

If you had something like this

$subject = $HTTP_POST_VARS["textfield"];
$toemail = "you@yourdomain.com";
$message = "put your message stuff in this var";
$headers = "From: " . $HTTP_POST_VARS["theiremail"] . "\nContent-type: text/html\n";

mail($toemail,$subject,$message,$headers);

that gives you the ability to set each of the individual parts of the email.

<added>ok, so I just noticed the small type that says ".pl" and this is a php answer, I am looking up perl mail now.

jatar_k

6:16 pm on Sep 10, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



OK, found it

Mail::Send [search.cpan.org]

Aquaholic

7:00 pm on Sep 10, 2002 (gmt 0)

10+ Year Member


The script I am using to process my html form is FormMail.pl

The config arrays must not have space must have underscore seperating words.
__________
*FormMail.pl source*
*
# Define the configuration associative array. #
%Config = ('recipient','', 'subject','',
'email','', 'realname','',
'redirect','', 'bgcolor','',
'background','', 'link_color','',
'vlink_color','', 'text_color','',
___________
Now because in my html form I must have the input name specific with a space because I am passing the email to another program that parces data based on key words. I cannot use a config array to capture that input name and print it to the Subject field.
_________
html source
*
<td align="center">&nbsp;&nbsp;
AR Number:<FONT COLOR="#C40000">*</FONT>
<input name="AR Number" type="text" size="9" maxlength="9">

AR Number:*_______ <--as it appears on the html form

______
So what I need to know is if there is a way to take a field and assign either 2 different input names to the same single input value

or a way I can pass the data that is submitted in this field over to the print subject line or append the already existing subject value.
______
html source:
*
<input type="hidden" name="subject" value="AR Update">

_____

______

FormMail source:

print MAIL "From: $Config{'email'}\n";
print MAIL "To: $Config{'recipient'}\n";
print MAIL "Cc: $Config{'cc'}\n";

# Check for Message Subject
if ($Config{'subject'}) { print MAIL "Subject: $Config{'subject'}\n\n"}
else { print MAIL "Subject: WWW Form Submission\n\n" }

jatar_k

7:48 pm on Sep 10, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>>2 different input names to the same single input value

No

So I don't really know perl syntax so you will have to figure that out yourself (is "." the cat operator in perl?)

use a new var to put together the parts that you want in your subject, ie

$newsubject = $Config{'subject'} . $whatever;

then don't compare for the subject and just put the new var name in the "print MAIL" command

print MAIL "From: $Config{'email'}\n";
print MAIL "To: $Config{'recipient'}\n";
print MAIL "Cc: $Config{'cc'}\n";
print MAIL "Subject: $newsubject\n\n";

that should work but you will have to test it out to get it right.