簡體   English   中英

WordPress聯絡表格無法使用

[英]Wordpress contact form won't work

所以這是我第一次使用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/

名稱為“ name”的輸入字段會導致該情況。 將其更改為“用戶名”之類的名稱,它應該開始工作。 我有類似的問題。 如果您想查看源代碼,請參閱我的類似問題

聯系人表格在Wordpress中不起作用

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM