I have a mailer that allows people to submit questions and request an email newsletter signup.
I don't know how to make the radio button information appear in my forwarded email. I am realy new to php script. (last time i wrote code was 7 years ago and that was VB).
So this is the code I use to generate the two emails. One goes to me and the other goes to the user. I was trying to figure out how to make it send two different emails depending on if the radio button was selected. Basicaly one to say thanks for the interest someone will contact you soon. The other to say the same but with the line Thank you for signing up for our email newsletter added to the end.
First code is my form.(don't kill me for using tables)
HTML Code:
<table align="center" style="font; width: 400px;" cellspacing="3" cellpadding="3">
<tr><td>
First Name<br />
<input size="25" name="FirstName" class="style116" style="width: 190px"/></td>
<td class="style116" colspan="2"> Last Name<br />
<input size="25" name="LastName" class="style116"/></td></tr>
<tr><td colspan="3">
Address<br />
<input size="54" name="Address" class="style116"/></td></tr>
<tr><td>
City<br />
<input size="25" name="City" class="style116"/></td><td>
State /Province<br />
<input size="13" name="State" class="style116"/></td><td>
Zip Code<br />
<input size="9" name="Zip" class="style116"/></td></tr>
<tr><td> Country (if not in the US)<br />
<input size="25" name="Country" class="style116"/></td><td colspan="2">
</td></tr>
<tr><td> Phone<br />
<input size="25" name="Phone" class="style116"/></td>
<td colspan="2">
E-mail<br />
<input size="25" name="Email" class="style116"/></td></tr>
<tr><td colspan="3" align="center" class="style116">
Comments or Questions<br />
<textarea name="Comments" rows="5" cols="52" class="style116"></textarea></td></tr> <tr>
<td colspan="3" class="style117">
<input name="remail" type="radio" /> Check here to sign up for the
mysite E-mail newsletter</td></tr> <tr>
<td colspan="3" class="style117">
<input type="reset" class="btn" value=" Clear " name="Clear1"/> <input type="submit" name="send" value="Submit"/> </td></tr> </table> </form>
</td>
</tr>
</table>
and this it the php page that the form submits to.
PHP Code:
<?php ini_set("sendmail_from",$_REQUEST['Email']); $to = "webmaster@mysite.org" ; $from = $_REQUEST['Email'] ; $name = $_REQUEST['FirstName'] ; $headers = "From: $from"; $subject = "Web Contact Data"; $fields = array(); $fields{"FirstName"} = "First Name"; $fields{"LastName"} = "Last Name"; $fields{"Address"} = "Address"; $fields{"City"} = "City"; $fields{"State"} = "State"; $fields{"Zip"} = "Zip"; $fields{"Country"}= "Country"; $fields{"Phone"}= "Phone"; $fields{"Email"}= "E-mail"; $fields{"Comments"}= "Comments"; $body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]);} $headers2 = "From: noreply@mysite.org"; $subject2 = "Thank you for contacting us"; $autoreply = "Thank you for contacting us. Someone will get back to you as soon as possible."; if($from == '') {print "You have not entered an email, please go back and try again";} else { if($name == '') {print "You have not entered a name, please go back and try again";} else { $send = mail($to, $subject, $body, $headers); $send2 = mail($from, $subject2, $autoreply, $headers2); if($send) {header( "Location: http://www.mysite.org/Contact" ); } else {print "We encountered an error sending your mail, please notify webmaster@mysite.org"; } } } ?>
So I don't understand how to make the radio button work properly.
Thanks for any help
Chris
|