我无法使用.php联系表单。
加载email_sent.php;但是,信息永远不会发送到指定的电子邮件。我的变量名称是错误的还是缺少功能代码的一部分?
<?php
//if "email" variable is filled out, send email
if (isset($_REQUEST['email'])) {
//Email information
$admin_email = "rogue_04_06@yahoo.com";
$name = $_REQUEST['name']
$email = $_REQUEST['email'];
$subject = $_REQUEST['subject'];
$messsage = $_REQUEST['message'];
//send email
mail($admin_email, $name, "$subject", $message, "From:" . $email);
//Email response
echo "Your information has been submitted. Thank you for contacting us!.";
}
//if "email" variable is not filled out, display the form
else {
?>
<form id="Contact Form" class="two" method="POST" action="email_sent.php">
<fieldset>
<legend>E-mail Us</legend>
<p>Enter your information below along with your questions and/or suggestions.</p>
<label>
Name
<input type="text" name="name" placeholder="John Smith">
<span id="name_validation" class="error_message"></span>
</label>
<label>
E-Mail
<input type="email" name="email"placeholder="address@domain.com">
<span id="email_validation" class="error_message"></span>
</label>
<div>
<label>Subject</label>
<div class="styled-select">
<select name="subject">
<option value="Option1">Question</option>
<option value="Options2">Suggestion</option>
<option value="Option3">Free Trial</option>
</select>
</div>
</div>
<label>Message</label>
<textarea name="message" id="message" placeholder="Type message"></textarea>
<button name="submit">
<strong>SEND</strong>
</button>
</fieldset>
</form>
<?php
}
?>
答案 0 :(得分:1)
注意这一点,;
缺失:
$name = $_REQUEST['name']
好像你忘记了(;)。
$name = $_REQUEST['name'];
第二点是您没有安装 SMTP服务器,而是使用mail()
功能,我建议使用此库PHPMailer,更安全。