Member 13638897 Ответов: 1

Проблема с контактной формой. Нужна помощь, пожалуйста!


Кажется, я не могу заставить кнопку "отправить" работать на моей контактной форме, чтобы отправить форму на адрес электронной почты. Кто-нибудь может помочь?

<div class="page-width">
  <div class="grid">
    <div class="grid__item medium-up--five-sixths medium-up--push-one-twelfth">
      <div class="section-header text-center">
        <style>
     
        </style>
                <h1>{{ page.title }}</h1>
      </div>
      {% if page.content.size > 0 %}
        <div class="rte">
          {{ page.content }}
        </div>
      {% endif %}

      <div class="contact-form form-vertical">
        {% form 'contact' %}
<div class="position_content" id="widgetu94_position_content">
<style>
     .column {
      float: left;
      width: 50%;
    }
    /* clear floats after the columns */
    .row:after {
      content: "";
      display: table;
      clear: both;
    }
.form-wrapper .field-list .field {
  position: relative;
  margin: -20px 0px 24px;
}
    </style>
  
    <div class="row">
      <div class="column" id="column_gap">
       <div>
      <label for="text">First Name:</label>
      <input type="text" id="first name" maxlength="10" required>
      </div>
      <div>
        <label for="text">Company:</label>
     <input type="text" id="company" maxlength="20">
        </div>       
      </div> 
      <div class="column" id="column_gap">
      </div>
 <div class="column" id="column_gap">
   <div>
    <label for="text">Last Name:</label>
    <input type="text" id="last name" maxlength="10" required>
    </div>
<div>
      <label for="text">Phone Number:</label>
    <input type="text" id="number" maxlength="12" required>
    </div>
      </div> </div>
  <div>
    <label for="text">Email Address:</label>
    <input type="text" id="email" maxlength="30" required></div>
<br><br>
      <div class="row">
      <div class="column" id="column_gap">
       <div>
      <label for="text">Rod Diameter (mm):</label>
      <input type="text" id="rod diameter" maxlength="5">
      </div>
      <div>
        <label for="text">Stroke (mm):</label>
     <input type="text" id="stroke" maxlength="5">
        </div>       
              <div>
        <label for="text">Extended Length (mm):</label>
     <input type="text" id="ex length" maxlength="5">
        </div>
      </div> 
 <div class="column" id="column_gap">
   <div>
    <label for="text">Tube Diameter (mm):</label>
    <input type="text" id="tube diameter" maxlength="5">
    </div>
<div>
      <label for="text">Closed Length (mm):</label>
    <input type="text" id="cl length" maxlength="5">
    </div>
      <div>
    <label for="text">Force Required (N):</label>
    <input type="text" id="force" maxlength="5">
    </div>
        </div> </div>

  <style>
    .column_gap {
      -webkit-column-count: 2;
      -moz-column-count: 2;
      column-count: 2;
      -moz-column-gap: 2em;
      -webkit-column-gap: 2em;
      column-gap: 2em;
    }
    .column {
      float: left;
      width: 50%;
    }
    /* clear floats after the columns */
    .row:after {
      content: "";
      display: table;
      clear: both;
    }
    </style>
  
    <div class="row">
      <div class="column">
    <div class="inline-field">
      <style>
        .inline-field input,
        .inline-field label {
          display: inline-block;
          margin-bottom: 0;
          vertical-align: middle;
        }
      </style>
      <input type="checkbox" id="checkbox">
      <label for="checkbox">Extended Gas Spring</label>
    </div>
      <div class="inline-field">
      <style>
        .inline-field input,
        .inline-field label {
          display: inline-block;
          margin-bottom: 0;
          vertical-align: middle;
        }
      </style>
            <input type="checkbox" id="checkbox">
      <label for="checkbox">Standard Build</label>
    </div>
          <div class="inline-field">
      <style>
        .inline-field input,
        .inline-field label {
          display: inline-block;
          margin-bottom: 0;
          vertical-align: middle;
        }
      </style>
      <input type="checkbox" id="checkbox">
      <label for="checkbox">Stainless Steel 316</label>
    </div>
          <div class="inline-field">
      <style>
        .inline-field input,
        .inline-field label {
          display: inline-block;
          margin-bottom: 0;
          vertical-align: middle;
        }
      </style>
            <input type="checkbox" id="checkbox">
      <label for="checkbox">Locking External (with Cover)</label>
    </div>
              <div class="inline-field">
      <style>
        .inline-field input,
        .inline-field label {
          display: inline-block;
          margin-bottom: 0;
          vertical-align: middle;
        }
      </style>
      <input type="checkbox" id="checkbox">
      <label for="checkbox">Locking Internal (Lever)</label>
    </div>
              <div class="inline-field">
      <style>
        .inline-field input,
        .inline-field label {
          display: inline-block;
          margin-bottom: 0;
          vertical-align: middle;
        }
      </style>
<input type="checkbox" id="checkbox">
      <label for="checkbox">Adjustment Valve (Side)</label>
    </div>
                  <div class="inline-field">
      <style>
        .inline-field input,
        .inline-field label {
          display: inline-block;
          margin-bottom: 0;
          vertical-align: middle;
        }
                    </style> </div> </div>
                            <div class="column">
    <div class="inline-field">
            <input type="checkbox" id="checkbox">
      <label for="checkbox">Compress (Traction)</label>
    </div>
          <div class="inline-field">
      <style>
        .inline-field input,
        .inline-field label {
          display: inline-block;
          margin-bottom: 0;
          vertical-align: middle;
        }
      </style>
    <input type="checkbox" id="checkbox">
      <label for="checkbox">Stainless Steel 304</label>
    </div>
      </div>
      <div class="column">
          <div class="inline-field">
      <style>
        .inline-field input,
        .inline-field label {
          display: inline-block;
          margin-bottom: 0;
          vertical-align: middle;
        }
      </style>
   <input type="checkbox" id="checkbox">
      <label for="checkbox">Locking Internal (Button)</label>
    </div>
              <div class="inline-field">
      <style>
        .inline-field input,
        .inline-field label {
          display: inline-block;
          margin-bottom: 0;
          vertical-align: middle;
        }
      </style>
      <input type="checkbox" id="checkbox">
      <label for="checkbox">Locking Internal (Own)</label>
    </div>
              <div class="inline-field">
      <style>
        .inline-field input,
        .inline-field label {
          display: inline-block;
          margin-bottom: 0;
          vertical-align: middle;
        }
      </style>
      <input type="checkbox" id="checkbox">
      <label for="checkbox">Adjustment Valve (Enclosed)</label>
        </div></div></div>
   <br>
       <div>
    <label for="text">End Fitting Requirements:</label>
    <input type="text" id="requirements" maxlength="300"></div>
     <div>
    <label for="text">Special Requirements:</label>
    <input type="text" id="sprequirements" maxlength="300"></div>
  
      </div> 
      <button class="submit-btn NoWrap rounded-corners clearfix colelem" id="u96-4" data-muse-temp-textContainer-sizePolicy="true" data-muse-temp-textContainer-pinning="true" type="submit" value="Submit" tabindex="25"><!-- content -->
       <div style="border-radius: 8px; height:11px; width: 200px; height: 25px; text-align= center; text-align= middle; ">
        <p>Submit</p>
       </div>
          {% if form.posted_successfully? %}
            <p class="note form-success">
              {{ 'contact.form.post_success' | t }}
            </p>
          {% endif %}


        {% endform %}
      </div>
    </div>
  </div>
</div>


Что я уже пробовал:

Пробовал разные типы контактных форм, но это единственная форма, которую я мог построить, которая имела правильный макет, который я хотел.

1 Ответов

Рейтинг:
0

Altaf Ansari

Код, который вы опубликовали, не содержит никакой формы.. поэтому он не будет работать как форма и не будет генерировать тип действия postback.. и вы не можете отправлять электронную почту без серверного языка, такого как php, asp или c#.. если вы используете html с php, то попробуйте что-то вроде этого:

<?php
    if(isset($_POST['name']))
    {
    $name = trim($_POST["name"]);
    $email = trim($_POST["email"]);
    $subject = trim($_POST["subject"]);
    $message = trim($_POST["message"]);
    $answerbox = trim($_POST["answerbox"]);
    if(strlen($name)<2) {
        print "<p>Please type your name.</p>";
    }else if(strlen($subject)<2) {
        print "<p>Please type a subject.</p>";
    }else if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
        print  "<p>Please type a valid email address.</p>";
    }else if(strlen($message)<10) {
        print "<p>Please type your message.</p>";
    }else if($answerbox != 15) {
        print "<p>Please answer the math question.</p>";
    }else{
                $headers =  'From: '.$email. "\r\n" .
                            'Reply-To: '.$email . "\r\n" .
                            'X-Mailer: PHP/' . phpversion();
        mail('me@mymail.me',$subject,$message,$headers);
        print "mail succesuffully sent";
    }

}
    ?>

        <form name="contact" action="form2.php" method="post">
            <input type="hidden" name="submitted" value="true"/>
            <label for="YourName">Your Name:</label>
            <input type="text" name="name" class="required" />

            <label for="YourEmail">Your Email:</label>
            <input type="text" name="email" class="required"/>

            <label for="Subject">Subject:</label>
            <input type="text" name="subject" class="required"  />

            <label for="YourMessage">Your Message:</label>
            <textarea  name="message" class="required"></textarea>
            <p class="c3">10 + 5 =<input type="text" name="answerbox" id="answerbox" /></p>

        <fieldset>
            <input type="submit" name="submit" id="submit" value="Send" class="required"/>
            <input type="reset" id="reset" value="Reset"/>      
        </fieldset>

    </form>