所以这是我第一次使用wordpress所以我的知识相对较小,但是我用html和css制作并设计了一个联系表格我现在试图激活表单以便将数据发送到我的电子邮件,但不管是什么我似乎什么也没做。
这是我目前使用的代码
<?php
/* template name: contact Page*/
?>
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$from = 'From: TangledDemo';
$to = 'kazumajshimizu@gmail.com';
$subject = 'Hello';
?>
<?php get_header(); ?>
<div id='main-content'>
<div id="page_title" class=" animated fadeIn delay1 duration2" >
<h1>CONTACT</h1>
<br>
<p> I would love to hear fom you, so please feel free to get in touch and contact me for any enquires or further information. </p>
<div class="fade_line"></div>
</div>
<div class="main_about">
<div id="wrapper_two">
<div id="left_one" class="animated fadeInDown delay3 duration2">
<form action="page_contact.php" method="post" class="contact_form" >
<label for="Name">
<input id="name" type="text" name="name" placeholder="NAME" />
</label>
<label for="Email">
<input id="email" type="email" name="email" placeholder="EMAIL" />
</label>
<label for="message">
<textarea id="message" name="message" placeholder="MESSAGE"></textarea>
</label>
<button name="submit" type="submit" class="button_send" value="send">SEND</button>
</form>
</div>
<div id="right_one" class="animated fadeInDown delay3 duration2">
<div id="map"></div>
<br>
<br>
<br>
<h3> Adress </h3>
<p>7 Silvabank CRT, Warner, 4500, Qld, Australia</p>
<br>
<h3>Phone</h3>
<p>0403144971</p>
<br>
<h3> Email </h3>
<p>kazumajshimizu@gmail.com</p>
</div>
</div>
<div id="insta" class="animated fadeInDown delay3 duration2">
<h3>INSTAGRAM</h3>
<div class="fade_line"></div>
<?php echo do_shortcode('[instagram-feed]'); ?>
</div>
</div>
<?php get_footer(); ?>
</div>
<script src="https://maps.googleapis.com/maps/api/js"></script>
<script>
function initialize() {
var mapCanvas = document.getElementById('map');
var mapOptions = {
center: new google.maps.LatLng(-27.4667, 153.0333),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(mapCanvas, mapOptions)
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
我也试过这个
<?php
/* template name: contact Page*/
?>
<?php
//response generation function
$response = "";
//function to generate response
function generate_response($type, $message){
global $response;
if($type == "success") $response = "<div class='success'>{$message}</div>";
else $response = "<div class='error'>{$message}</div>";
}
//response messages
$not_human = "Human verification incorrect.";
$missing_content = "Please supply all information.";
$email_invalid = "Email Address Invalid.";
$message_unsent = "Message was not sent. Try Again.";
$message_sent = "Thanks! Your message has been sent.";
//user posted variables
$name = $_POST['message_name'];
$email = $_POST['message_email'];
$message = $_POST['message_text'];
$human = $_POST['message_human'];
//php mailer variables
$to = get_option('admin_email');
$subject = "Someone sent a message from ".get_bloginfo('name');
$headers = 'From: '. $email . "\r\n" .
'Reply-To: ' . $email . "\r\n";
if(!$human == 0){
if($human != 2) generate_response("error", $not_human); //not human!
else {
//validate email
if(!filter_var($email, FILTER_VALIDATE_EMAIL))
generate_response("error", $email_invalid);
else //email is valid
{
//validate presence of name and message
if(empty($name) || empty($message)){
generate_response("error", $missing_content);
}
else //ready to go!
{
$sent = mail($to, $subject, $message, $headers);
if($sent) generate_response("success", $message_sent); //message sent!
else generate_response("error", $message_unsent); //message wasn't sent
}
}
}
}
else if ($_POST['submitted']) generate_response("error", $missing_content);
?>
<?php get_header(); ?>
<style type="text/css">
.error{
padding: 5px 9px;
border: 1px solid red;
color: red;
border-radius: 3px;
}
.success{
padding: 5px 9px;
border: 1px solid green;
color: green;
border-radius: 3px;
}
form span{
color: red;
}
</style>
<div id='main-content'>
<div id="page_title" class=" animated fadeIn delay1 duration2" >
<h1>CONTACT</h1>
<br>
<p> I would love to hear fom you, so please feel free to get in touch and contact me for any enquires or further information. </p>
<div class="fade_line"></div>
</div>
<div class="main_about">
<div id="wrapper_two">
<div id="left_one" class="animated fadeInDown delay3 duration2">
<div id="respond">
<?php echo $response; ?> </div>
<form class="contact_form"action="<?php the_permalink(); ?>" method="post" >
<label for="Name">
<input type="text" name="message_name" placeholder="NAME" value="<?php echo $_POST['message_name']; ?>">
</label>
<label for="Email">
<input type="text" name="message_email" placeholder="EMAIL" value="<?php echo $_POST['message_email']; ?>">
</label>
<label for="message">
<textarea id="message" name="message_human" placeholder="MESSAGE"></textarea>
</label>
<button id="submit" name="submit" type="submit" class="button_send" value="send">SEND</button>
</form>
</div>
<div id="right_one" class="animated fadeInDown delay3 duration2">
<div id="map"></div>
<br>
<br>
<br>
<h3> Adress </h3>
<p>7 Silvabank CRT, Warner, 4500, Qld, Australia</p>
<br>
<h3>Phone</h3>
<p>0403144971</p>
<br>
<h3> Email </h3>
<p>kazumajshimizu@gmail.com</p>
</div>
</div>
</div>
<div id="insta" class="animated fadeInDown delay3 duration2">
<h3>INSTAGRAM</h3>
<div class="fade_line"></div>
<?php echo do_shortcode('[instagram-feed]'); ?>
</div>
</div>
<?php get_footer(); ?>
</div>
<script src="https://maps.googleapis.com/maps/api/js"></script>
<script>
function initialize() {
var mapCanvas = document.getElementById('map');
var mapOptions = {
center: new google.maps.LatLng(-27.4667, 153.0333),
zoom: 8,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(mapCanvas, mapOptions)
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
似乎都不起作用。任何人都可以给予我任何帮助将非常感激,因为我花了好几个小时试图解决这个问题。这是我的网站http://shimizudesigns.com/contact/
的链接答案 0 :(得分:0)
名称为“name”的输入字段会导致它。将其更改为“用户名”之类的其他内容,它应该开始工作。我遇到过类似的问题。如果您想查看源代码,请参阅我的类似问题