所以,我已经为wordpress创建了一个php网页(只是新的内容)。我的问题是因为我找不到任何wordpress插件来更好地为我的自定义布局做这件事。我想自己创建一个联系表单,我尽力创建这个脚本,但我认为它不起作用,我没有收到邮箱中的任何电子邮件。是因为我在localhost吗?或者是脚本中的问题?
<?php
/*
Template Name: Contact Page Layout.
*/
get_header();
?>
<div id="content" style="padding-top: 8em; background: none;">
<?php
if (have_posts()):
while (have_posts()):
the_post();
?>
<div id="contacttable">
<ul>
<li class="google-maps block" id="first-block">
<?php echo do_shortcode('[wpgmza id="1"]');?>
</li>
<li class="info block" id="second-block">
<?php the_content(); ?>
</li>
<li class="quote block" id="third-block">
<h3> <?php the_title(); ?> </h3>
</li>
<li class="message block" id="forth-block">
<?php
$action = $_REQUEST['POST'];
if ($action == "") /* display the contact form */ { ?>
<form action="" method="POST" enctype="multipart/form-data">
<textarea name="message" rows="7" cols="30" id="myTextarea"></textarea><br>
<input type="submit" id="submit" value="Send."/>
</form>
</li>
<li class="picture block" id="fifth-block">
<img src="wp-content/themes/gcustom/img/contact_img.png" height="100%" style="maxwidth: 100%;">
</li>
<li class="email block" id="sixth-block">
<input name="email" type="text" value="" size="30" id="email"/><br>
<?php
} else {
$email = $_REQUEST['email'];
$message = $_REQUEST['message'];
if (($email == "") || ($message == "")) {
alert("All fields are required, please fill <a href=\"\">the form</a> again.");
$message = "not sended";
echo "<script type='text/javascript'>alert('$message');</script>";
} else {
$message = "sended";
echo "<script type='text/javascript'>alert('$message');</script>";
$admin_email = get_option('admin_email');
$from = "From: <$email>\r\nReturn-path: $email";
$subject = "Message from your G-CUSTOM contact-form!";
mail($admin_email, $subject, $message, $from);
echo "Email sent!";
}
}
?>
</li>
</ul>
</div>
<?php
endwhile;
endif;
?>
</div>
<script type="text/javascript">
document.getElementById("myTextarea").value = "Hello,";
document.getElementById("email").value = "Enter your email.";
</script>
<?php get_footer(); ?>