Forum Moderators: mack

Message Too Old, No Replies

How to append user inputs into form subject field

forms and subject field

         

RegH

7:52 pm on Mar 21, 2008 (gmt 0)

10+ Year Member



Hi - I am wondering if there is a simple way to add a user selected choice to the subject line of a form. I understand how to make a hidden php field to add the subject to the form when submitted, but I also want to add additional information to the subject. For example, if I have a free version of a newsletter or a chargable version, selected by a radio button, I would like the words "free" or "paid" add to the subject field depending on the users choice.

Any suggestions - I am not a php programmer, but am willing to give anything a try.
Thanks in advance.

[edited by: RegH at 8:06 pm (utc) on Mar. 21, 2008]

surrealillusions

9:42 pm on Mar 21, 2008 (gmt 0)

10+ Year Member



Depends on how you collect the information. If you collect each bit of data as a variable, then you can add a subject into the mailing bit of the script,

$subject = "Subject: " . $_POST['formfield1' . $_POST['formfield2'];

// rest of the message and whatever else you want to include in the email goes here.

if (mail($to,$subject,$message,$headers)) {
echo "Message Sent!"; // success

hope that helps

:)

RegH

10:01 pm on Mar 21, 2008 (gmt 0)

10+ Year Member



Hi

Your answer is very clear and I think I can make it work, but my skills are really weak.

I am using this bit of code to post the form.
<form action="formmail/formmail.php" method="post" enctype="multipart/form-data" id="FrontPage_Form2">

Is it in these brackets that I should use your suggestion.

Thanks a lot for your help

RegH

10:09 pm on Mar 21, 2008 (gmt 0)

10+ Year Member



By the way, here is the site link.

I am trying get the value of the radio button to show up in the subject field. I would like to keep the field hidden too, if possible.
Thanks

[edited by: RegH at 10:29 pm (utc) on Mar. 21, 2008]

surrealillusions

10:23 pm on Mar 21, 2008 (gmt 0)

10+ Year Member



As per the TOS, we dont allow site links.

Onto your previosu question. The code that i posted goes into the file thats linked here. -

action="formmail/formmail.php"

If the code isn't too long, could you post the contents of that file? (without compromising any security and such)

:)

RegH

10:34 pm on Mar 21, 2008 (gmt 0)

10+ Year Member



Thanks for the TOS notice - i took it out.

Here is the code

<form action="formmail/formmail.php" method="post" enctype="multipart/form-data" id="FrontPage_Form2">
<table width="100%" border="0" align="center" cellpadding="10" cellspacing="0">
<tr>
<td width="50%" valign="top"><font face="Arial, Helvetica, sans-serif" size="2" color="#333366"> <font face="Arial" size="2">
<input name="billme" type="radio" value="Trial Subscription" checked />
<span class="bodycopy">OK - Send </span></font></font><span class="bodycopy"><font face="Arial" size="2" color="#333366">me
a</font><font face="Arial, Helvetica, sans-serif" size="2" color="#333366">
complimentary issue of </font> </span><span class="bodycopy"><font face="Arial" size="2"><font face="Arial" size="2">the
newsletter. If I like
it, then I will be billed $290</font></font></span><span class="bodycopy"><font face="Arial" size="2"><font face="Arial" size="2"> for
an annual subscription. (12 issues)</font></font></span><font face="Arial" size="2"><font face="Arial" size="2"><br />
</font></font></td>
<td width="50%" valign="top"><font face="Arial, Helvetica, sans-serif" size="2" color="#333366">
<font face="Arial" size="2">
<input type="radio" name="billme" value="$290" />
<span class="bodycopy">Bill me for $</span>290</font> (or I will
pay securely below with a CC) </font></td>
</tr>
</table>

And here is the field currently in use for the subject field.

<input type="hidden" name="subject" value="Biometric Digest" />

I didn't write the original code, so I am having to learn everything at once. That being said I hope you have enough info.

Thanks

surrealillusions

6:58 pm on Mar 22, 2008 (gmt 0)

10+ Year Member



thats not the formmail.php ;)

Unless your process script is on the same file.

Your best bet is to have a read of this topic -

[webmasterworld.com...]

:)

RegH

7:35 pm on Mar 22, 2008 (gmt 0)

10+ Year Member



I really am a php knucklehead - thanks. But I understand a little better. I was looking at the client side, not the script side of the form functionality.

I will take a look and then see if I still have any questions.