由于固定链接,联系表格无法正常工作

时间:2014-05-31 09:31:52

标签: php wordpress forms submit permalinks

正在使用wordpress,我正在尝试提交表单。它没有被提交我想由于固定链接,请参阅下面的代码:

<?php
/*
Template Name: Contact 
*/
get_header();
get_template_part('/functions/page-title'); 
?>

<style>

textarea, input[type="text"] {
    width: 60%;
    max-width: 500px;
    box-sizing: border-box;
    height: 40px;
    -webkit-border-radius: 5px;
    -moz-border-radius: 5px;
    border-radius: 5px;
}
</style>

<link href="style.css" rel="stylesheet" type="text/css" />
<?php
// display form if user has not clicked submit
if (!isset($_POST["submit"])) {
    echo("not postttttttttt");
    echo(var_dump($_POST));
  ?>
<form method="post" >
  <div id="content" align="center">
  <div id="left-column">
    <div>
      <div class="page-title-block">
        <h3 class="page-title"><a href="<?php the_permalink(); ?>"></a></h3>
      </div>
      <div align="center" class="copy clearfix">
        <?php the_content(); ?>
        <div align="center" style="position:relative;  width900px; background-color:#454545; margin-top:20px; height:630px; ">
          <div style="position:absolute; left:33px; top:30px; color:#fff; font-size:14px; ">All fields are required.</div>
          <div style="position:absolute; left:34px; top:70px; color:#fff; font-weight:bold; font-size:15px; ">Full Name</div>
          <textarea name="fullname" style="position:absolute; top:90px; left:30px;  text-align:left;"></textarea>
          <div style="position:absolute; left:34px; top:130px; color:#fff; font-weight:bold; font-size:15px; ">Phone Number</div>
          <textarea name="phonenumber" style="position:absolute; top:150px; left:30px; text-align:left;"></textarea>
          <div style="position:absolute; left:34px; top:190px; color:#fff; font-weight:bold; font-size:15px; ">Email Address</div           >
          <textarea name="emailaddress" style="position:absolute; top:210px; left:30px; text-align:left;"></textarea>
          <div style="position:absolute; left:34px; top:250px; color:#fff; font-weight:bold; font-size:15px; ">Subject</div>
          <div class="cleanf twi_disp" style="position:absolute; top:270px; left:30px; width:358px; height:44px; text-align:left; background:url(images/field_358_44.png); ">
            <div id="fild1ov" style="position:absolute; font-size:16px; font-family:Arial, Helvetica, sans-serif; color:#666; left:10px; top:16px; ">
              <select name="subject">
                <option value="Select">Select</option>
                <option value="technical">Technical issue</option>
                <option value="commercial">Commercial issue</option>
              </select>
            </div>
          </div>
          <div style="position:absolute; left:34px; top:340px; color:#fff; font-weight:bold; font-size:15px; ">Description</div>
          <div class="msg" style="position:absolute; top:360px; left:30px; text-align:left; background:url(images/field_760_162.png); ">
            <textarea name="message" style="top:5px; left:4px; position:absolute;" class="msg"></textarea>
          </div>
          <input type="submit" value="submit" class="round-button" style="top:520px; left:30px; border-radius:5px;">
          <div style="position:absolute; left:30px; top:560px; color:#fff; font-size:14px; ">Please check your spam/junk folder if you do not receive a reply within the next 24 hours.</div>
        </div>
      </div>
    </div>
  </div>
</form>
<?php
} else {    // the user has submitted the form
  // Check if the "fullname" input field is filled out
    echo('qqqqqqqqqqqqqqqqq');
  if (isset($_POST["fullname"])) {  
    echo('sssssssssssssss');
    $fullname = $_POST["fullname"];
    $phonenumber = $_POST["phonenumber"]; // sender
    $subject = $_POST["subject"];
    $message = $_POST["message"];
    // message lines should not exceed 70 characters (PHP rule), so wrap it
    $message = wordwrap($message, 70);
    $to = "mohamed.kazma@windowslive.com";

 wp_mail( $to, $subject, $message, $headers, $attachments ); 
  }
}
?>
<?php get_footer(); ?>

当按下提交按钮时,代码没有进入应该发送电子邮件的php片段,因为我知道当我将邮件代码放在页面的开头时能够发送电子邮件。 加上我把echo(var_dump($ _ POST));值正在正确填充。

1 个答案:

答案 0 :(得分:1)

您忘记输入SUBMIT的“名称”属性。

您的代码:

<input type="submit" value="submit" class="round-button" style="top:520px; left:30px; border-radius:5px;">

修改后的代码:

<input type="submit" value="submit" name="submit" class="round-button" style="top:520px; left:30px; border-radius:5px;">