我正在Yahoo Small Business托管上创建一个网站,我在使用我在Bluehost上的WordPress安装时使用的PHP联系表单时遇到问题。表格是:
<?php
if(isset($_POST['submitted'])) {
if(trim($_POST['contactName']) === '') {
$nameError = 'Please enter your name.';
$hasError = true;
} else {
$name = trim($_POST['contactName']);
}
if(trim($_POST['email']) === '') {
$emailError = 'Please enter your email address.';
$hasError = true;
} else if (!preg_match("/^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$/i", trim($_POST['email']))) {
$emailError = 'You entered an invalid email address.';
$hasError = true;
} else {
$email = trim($_POST['email']);
}
if(!isset($hasError)) {
$emailTo = get_option('tz_email');
if (!isset($emailTo) || ($emailTo == '') ){
$emailTo = 'chris@bingetech.com';
}
$subject = '[PHP Snippets] From '.$name;
$body = "Name: $name \n\nEmail: $email \n\nComments: $comments";
$headers = 'From: '.$name.' <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;
wp_mail($emailTo, $subject, $body, $headers);
$emailSent = true;
}
} ?>
<div id="contact-wrap">
<?php if(isset($emailSent) && $emailSent == true)
{ ?>
<div class="thanks">
<p>Thanks, your email was sent successfully.</p>
</div>
<?php } else { ?>
<?php the_content(); ?>
<?php if(isset($hasError) || isset($captchaError)) { ?>
<p class="error">Sorry, an error occurred.<p>
<?php } } ?>
<form action="<?php the_permalink(); ?>" id="contactForm" method="post">
<ul class="formList">
<li>
<label class="contact_labels" for="contactName">Name:</label>
<input type="text" name="contactName" id="contactName" value="<?php if(isset($_POST['contactName'])) echo $_POST['contactName'];?>" class="required requiredField" />
<?php if($nameError != '') { ?>
<span class="error"><?=$nameError;?></span>
<?php } ?>
</li>
<li>
<label class="contact_labels" for="email">Email: </label>
<input type="email" name="email" id="email" value="<?php if(isset($_POST['email'])) echo $_POST['email'];?>" class="required requiredField email" />
<?php if($emailError != '') { ?>
<span class="error"><?=$emailError;?></span>
<?php } ?>
</li>
</ul>
<div id="subContain">
<input type="submit" id="submit" value="Ask Away!"></input>
</div>
<input type="hidden" name="submitted" id="submitted" value="true" />
</form>
</div>
我有适当的标题调用,这确实适用于Bluehost,从我的研究看来,Yahoo Small Business主机可能很棘手的联系表单/电子邮件。我怎么能绕过这个?
答案 0 :(得分:0)
您应该使用一些插件而不是您自己的PHP代码。尝试联系表格7,完全可以自定义