我已经设置了一个表单,通过电子邮件向我发送帖子值,我想知道我是否可以使用IF命令或类似的东西给不同的帐户发送电子邮件。
这里是html我需要什么PHP?
<form id="my-contact-form" action="contacts.php" method="post" role="form">
<div><input " name="my-contact-form" type="hidden" value="1" class="form-control"></div>
<fieldset>
<legend>Fill in this form to contact me</legend>
<label for="username">Your name : </label>
<input class="u-full-width" style="color:black" id="username" name="username" type="text" value="" >
<label for="useremail">Your email : </label>
<input class="u-full-width" style="color:black" id="useremail" name="useremail" type="email" value="" >
<label for="userphone">Your phone : </label>
<input style="color:black" id="userphone" name="userphone" type="text" value="" > <br>
<label for="reply">Best way to contact you : </label>
<input type="radio" id="reply" name="reply" value="phone">phone
<input type="radio" name="reply" value="email">email
<label for="subject">Subject : </label>
<select style="color:black" id="subject" name="subject" >
<option value="Support" >Support</option>
<option value="Sales" >Sales</option>
<option value="Other" >Other</option>
</select>
<button type="submit" name="submit-btn" value="1" style="color:white" class="btn btn-success">Submit</button>
</div>
&#13;
答案 0 :(得分:0)
以下代码是您选择电子邮件时应使用的代码。将电子邮件更改为您要使用的电子邮件。然后,$ email是已保存的电子邮件,并使用该电子邮件将该电子邮件用于电子邮件。
<?php
$subject = $_POST['subject'];
if($subject == 'sales'){
$email = "sales@example.com";
} else if($subject == 'support'){
$email = "support@example.com";
} else {
$email = "other@example.com";
}
?>
然后将其发送到该电子邮件地址:
<?php echo $email; ?>
您希望电子邮件显示在哪里以便发送。但是如果你有一个php邮件系统,那就放一个$ email。
非常基本,但应该帮助你继续前进。