/    Sign up×
Community /Pin to ProfileBookmark

Email combo – if a certain option is selected

Hi, i have a contact form, it has a topic field that has certain options as seen below. The form is emailed to [email][email protected][/email], however i want to set it up so that if a user selects the topic as advertising, it emails the form to [email][email protected][/email]. I want all the other topics to go to [email][email protected][/email] as normal.

Here is my form: (please note that the small bit of PHP in the code below is used to automatically select the advertising field, incase someone automatically selects the Advertise Here link on the home page)

[code=html]<form name=”registration” id=”Upload” action=”contact.processor.php” onSubmit=”return validate_form(this);” enctype=”multipart/form-data” method=”post”>
<table width=”70%” border=”0″ cellspacing=”1″ cellpadding=”0″>
<tr>
<td colspan=”2″ valign=”bottom”><img src=”images/contact.jpg”></td>
</tr>
<tr bgcolor=”#D9D9D8″>
<td width=”16%” class=”form”>Name:</td>
<td width=”84%”><input type=”text” name=”name” size=”35″ maxlength=”30″ tabindex=”1″></td>
</tr>
<tr bgcolor=”#D9D9D8″>
<td class=”form”>Topic:</td>
<td>

<?php
$topic = $_GET[‘topic’]
?>
<select style=”width: 185px” name=”topic” tabindex=”2″>
<option value=”null”>— Select Question Type —</option>
<option value=”Comment or Suggestion”>Comment or Suggestion</option>
<option value=”Cancel Membership”>Cancel Membership</option>
<option value=”Change Email Address”>Change Email Address</option>
<?php
if ($topic == ‘Advertising’) {
echo ‘<option value=”Advertising” selected=”selected”>Advertising</option>’;
} else {
echo ‘<option value=”Advertising”>Advertising</option>’;
}
?>
<option value=”Press”>Press</option>
<option value=”Business Partnerships”>Business Partnerships</option>
<option value=”other”>- OTHER -</option>
</select>

</td>
</tr>
<tr bgcolor=”#D9D9D8″>
<td class=”form”>Mobile:</td>
<td><input type=”text” name=”mobile” size=”12″ maxlength=”10″ value=”0871234567″ onFocus=”this.value=”;” class=”form_small_text_3″ tabindex=”3″>
</td>
</tr>
<tr bgcolor=”#D9D9D8″>
<td class=”form”>Email:</td>
<td><input type=”text” name=”email” size=”32″ maxlength=”49″ tabindex=”4″>
</td>
</tr>
<tr bgcolor=”#D9D9D8″>
<td class=”form”>Message:</td>
<td colspan=”2″ class=”text”><span class=”form_small_text_1″>
Please type your message below</span><br>
<textarea tabindex=”5″ cols=”50″ rows=”8″ name=”message” class=”form_small_text_3″ wrap=”physical
onKeyDown=”textCounter(this.form.message,this.form.remLen,1000);”
onKeyUp=”textCounter(this.form.message,this.form.remLen,1000); “onFocus=”this.value=”; this.onfocus=null;”>(Please include a contact number to help us speed up our response)</textarea>
<br>
<span class=”form_small_text”>Characters remaining:
<input readonly type=text name=remLen size=4 maxlength=4 value=”1000″>
</td>
</tr>
<tr bgcolor=”#D9D9D8″>
<td height=”35″>&nbsp;</td>
<td> <input name=”submit” tabindex=”6″ type=”submit” id=”submit” value=”Send”>
<input type=”reset” tabindex=”7″ name=”Reset” value=”Reset”></td>
</tr>
<tr>
<td colspan=”2″><img src=”images/contact_b.jpg”></td>
</tr>
</table>
</form>[/code]

Here is the email that is sent

[code=php] $todayis = date(“l, F j, Y, g:i a”) ;

$name = $_POST[‘name’];
$topic = $_POST[‘topic’];
$mobile = $_POST[‘mobile’];
$email = $_POST[’email’];
$message= $_POST[‘message’];
$message = stripcslashes($message);

$body = ” $todayis [EST] n
Name: $name n
Email: $email n
Topic: $topic n
Mobile: $mobile n

Message: $message n
“;

$from = “From: $emailrn”;

mail(“[email protected]”, $topic, $body, $from);[/code]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@oo7mlauthorJun 18.2007 — Sorted thanks

[code=php]
if ($topic == 'Advertising')
$to = "[email protected]";
else
$to = "[email protected]";

mail($to, $topic, $body, $from);[/code]
×

Success!

Help @oo7ml spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...