繁体   English   中英

无需Wordpress即可联系表格7功能

[英]contact form 7 functions without wordpress

我有一个使用引导框架构建的网站。

我想实现没有Wordpress的联系表7功能。 像这样用单选按钮。 我尝试将php邮件功能与引导程序一起使用,但无法像发送带有数据的电子邮件那样工作。

像这样的PHP自举程序,下面是代码

“ HTML从这里开始”

<div class="center"><br>
  <button type="button" class="preview btn btn-info btn-lg" data-toggle="modal" data-target="#requestInfo">Free Consultation!</button>
</div>
<!-- The Modal -->
<div id="requestInfo" class="modal">
  <!-- Modal content -->
  <div class="modal-content">
    <div role="form">
      <form method="post" action="modal_form.php" novalidate="novalidate">
        <div class="modal-header">
          <div class="center">
            <button type="button" class="close" data-dismiss="modal">&times;</button>
            <h4 class="modal-title">Free Consultation!</h4>
          </div>
        </div>

        <div class="modal-body"><br>

          <div class="form-group">
            <input type="text" name="name" id="name" value="" size="40" aria-invalid="false" placeholder="Name with Designation*" required/>
          </div>
          <div class="form-group">
            <input type="text" name="companyname" id="companyname" value="" size="40" aria-invalid="false" placeholder="Company's Name" />
          </div>
          <div class="form-group">
            <input type="email" name="email" id="email" value="" size="40" aria-invalid="false" placeholder="Email*" required />
          </div>
          <div class="form-group">
            <input type="tel" name="mobile" id="mobile" value="" size="40" aria-invalid="false" placeholder="Mobile" />
          </div>
          <div class="form-group">
            <input type="tel" name="state" id="state" value="" size="40" aria-invalid="false" placeholder="Any prefered State in India." />
          </div>

          <p class="lead">Help us to know more about your requirements</p>
          <h4>1. Purpose of Company*</h4>
          <div class="left-align">
            <div class="radio ">
              <label><input type="radio" name="PurposeOfCompany" id="manufacturing" value="Manufacturing Setup">Manufacturing Setup</label>
            </div>
            <div class="radio">
              <label><input type="radio" name="PurposeOfCompany" id="sectors" value="Sectors">Sectors</label>
            </div>
            <div class="radio">
              <label><input type="radio" name="PurposeOfCompany" id="investment" value="Investment">Investment/Finance</label>
            </div>
            <div class="radio">
              <label><input type="radio" name="PurposeOfCompany" id="trading" value="Trading">Trading</label>
            </div>
            <div class="radio">
              <label><input type="radio" name="PurposeOfCompany" id="jv" value="JV">Joint Venture / Mergers and Acquisitions</label>
            </div>
            <div class="radio">
              <label><input type="radio" name="PurposeOfCompany" id="other" value="Other">Others</label>
            </div>
            <div class="form-group" id="other_purpose" style="display: none;">
              <input type="text" name="PurposeOfCompany_Other" id="specify" value="" size="40" aria-invalid="false" placeholder="Specify" />
            </div>

            <div class="form-group">
              <textarea class="form-control" rows="4" id="details" placeholder="Details:"></textarea>
            </div>
            <p>* Mandatory Fields</p>
          </div>
          <div class="modal-footer">
            <div class="center">
              <input class="btn btn-info btn-md" type="submit" value="Submit" />
              <button type="button close" class="btn btn-info btn-sm" data-dismiss="modal">Close</button>
            </div>
          </div>
        </div>
      </form>

    </div>
  </div>
</div>

“ HTML在这里结束”

“ CSS从这里开始”

<style>
    /* The Modal (background) */
    .modal {
        display: none; /* Hidden by default */
        position: fixed; /* Stay in place */
        padding-top: 100px; /* Location of the box */
        left: 0;
        top: 0;
        width: 100%; /* Full width */
        height: 100%; /* Full height */
        overflow: auto; /* Enable scroll if needed */
        background-color: rgb(0,0,0); /* Fallback color */
        background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
    }

    /* Modal Content */
    .modal-content {
        position: relative;
        background-color: #fefefe;
        margin: auto;
        padding: 10px;
        border: 1px solid #888;
        width: 70%;
        box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
        -webkit-animation-name: animatetop;
        -webkit-animation-duration: 0.4s;
        animation-name: animatetop;
        animation-duration: 0.4s
    }

    /* Add Animation */
    @-webkit-keyframes animatetop {
        from {top:-300px; opacity:0} 
        to {top:0; opacity:1}
    }

    @keyframes animatetop {
        from {top:-300px; opacity:0}
        to {top:0; opacity:1}
    }

    /* The Close Button */
    .close {
        float: center;
        font-size: 28px;
        font-weight: bold;
    }

    .close:hover,
    .close:focus {
        color: #000;
        text-decoration: none;
        cursor: pointer;
    }

    .modal-header {
        padding: 0px 5px 5px 0px;
        font-size: 25px;
        font-weight: bold;

    }

    .modal-footer {
        padding: 5px 0px 0px 0px;
        font-size: 25px;
        font-weight: bold;

    }

    .modal-body {padding: 20px 20px;}

    }   
</style>

“ CSS在这里结束”

“ JS从这里开始”

<script>
    $(document).ready(function(){
        $('input[name=PurposeOfCompany]').change(function(){
            if($(this).val() === 'Other') {
                $('#other_purpose').show();
            } else {
                $('#other_purpose').hide();
            }
        });
    })
</script>

“ JS在这里结束”

“ Php从这里开始”

<?php
  $name    = $_POST['name'];
  $cname    = $_POST['cname'];
  $email   = stripslashes($_POST['email']);
  $phone   = stripslashes($_POST['phone']);
  $purpose = $_POST['purpose'];
  $message = $_POST['message'];
  $form_message = "Name: $name \nCompany's Name: $cname \nEmail: $email \nPhone: $phone \nPurpose of Contact: $purpose \nMessage: $message";

  header( "Location: http://www.example.com");

  mail("freeconsultancy@example.com", "Free Consultancy Message!", $form_message, "From: $email" );

?>

“ Php在这里结束”

当我单击提交按钮时,php函数不发送数据。

不要使用PHP邮件功能。 使用PHPMailer

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM