M
M
Maxim2020-05-14 17:01:38
PHP
Maxim, 2020-05-14 17:01:38

Why is the feedback form not working correctly?

Hello to all readers!)

In general, there is a form, not written by me, taken for use))
Here is php

<?php 
  $errors = '';
  $limit_size=10000000;
  $myemail = 'МЫЛО'; 
  if(empty($_POST['name'])  ||
     empty($_POST['email']) ||
     empty($_POST['subject']) ||
     empty($_POST['message']))
  {
  $errors .= "\n Error: Required Field";
  }	

    /*data*/
  $name = $_POST['name'];
  $email = $_POST['email'];
  $subject = $_POST['subject'];
  $message = $_POST['message'];
  $headers = "From: $email";

  if (!eregi(
  "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", 
  $email))
  {
  $errors .= "\n Error: Invalid Email Address";
  }

  if( empty($errors))
  {
  $to = $myemail;
  $email_subject = "A New Message Awaits: $subject";
  $txt = "You have received a new message from your website. Details are given below.\n Name: $name \n Email: $email \n Subject: $subject \n Message: \n $message";
  
  // preparing attachments
  $files = array();
    if($file_one)
     {
     array_push($files,$file_one);
   }	  
   
    $semi_rand = md5(time()); 
    $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; 
    $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; 
    $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $txt . "\n\n"; 
    $message .= "--{$mime_boundary}\n";
    
      for($x=0;$x<count($files);$x++){
      $file = fopen('tmp/'.$files[$x],"rb");
      $data = fread($file,filesize('tmp/'.$files[$x]));
      fclose($file);
      $data = chunk_split(base64_encode($data));
      $message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$files[$x]\"\n" . 
      "Content-Disposition: attachment;\n" . " filename=\"$files[$x]\"\n" . 
      "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
      $message .= "--{$mime_boundary}\n";
    }
 
  mail($to, $email_subject, $message, $headers);
  }
?>

Here is the html
<section id="contact" class="contact_area">
      <div class="container-fluid">
        <div class="row">		
          <div class="col-lg-6 col-sm-12 col-xs-12 no-padding" data-aos="fade-up">
            <div class="contact_address">
              <h3>Контакты</h3>				
              <ul>
                <li><i class="fa fa-envelope"></i>мыло@gmail.com</li>
                <li><i class="fa fa-calendar"></i>Понедельник - Пятница</li>
                <li><i class="fa fa-clock-o"></i>9:00 - 17:00</li>
              </ul>
            </div>
          </div><!-- END COL -->						
          <div class="col-lg-6 col-sm-12 col-xs-12 no-padding" data-aos="fade-up">
            <div class="contact">
              <form id="contact-form" method="post" enctype="multipart/form-data">
                <div class="row">
                  <div class="form-group col-md-6">
                    <input type="text" name="name" class="form-control" id="first-name" placeholder="Имя" required="required">
                  </div>
                  <div class="form-group col-md-6">
                    <input type="email" name="email" class="form-control" id="first-email" placeholder="Email" required="required">
                  </div>
                  <div class="form-group col-md-12">
                    <input type="text" name="subject" class="form-control" id="subject" placeholder="Тема" required="required">
                  </div>
                  <div class="form-group col-md-12">
                    <textarea rows="6" name="message" class="form-control" id="description" placeholder="Сообщение" required="required"></textarea>
                  </div>
                  <div class="col-md-12">
                    <div class="actions">
                      <input type="submit" value="Отправить" name="submit" id="submitButton" class="btn btn-lg btn-contact-bg" title="Подтвердите Ваше сообщение!" />
                    </div>
                  </div>
                </div>
              </form>
            </div>
          </div>
        </div>			
      </div>	
    </section>


The bottom line is that the "Submit" button changes color on hover, but is not clickable, as I understand it. Nothing happens when you click. It is

necessary that the data entered be actually sent ..)
Be so kind as to tell me where and what I'm doing wrong?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
Kirill Nikitin, 2020-05-14
@lognog

How does html know about php? The action="" attribute of the form tag is missing.

D
drawnofmymind, 2020-05-14
@drawnofmymind

Hmm .. do you indicate email as “soap”?

M
Maxim, 2020-05-14
@lognog

Here is the JS

$(document).ready(function() {
  $('form#contact-form').submit(function() {
  $('form#contact-form .error').remove();
  var hasError = false;
  $('.requiredField').each(function() {
  if(jQuery.trim($(this).val()) == '') {
    var labelText = $(this).prev('label').text();
    $(this).parent().append('<span class="error">Вы забыли ввести '+labelText+'</span>');
    $(this).addClass('inputError');
    hasError = true;
    } else if($(this).hasClass('email')) {
    var emailReg = /^([\w-\.][email protected]([\w-]+\.)+[\w-]{2,4})?$/;
    if(!emailReg.test(jQuery.trim($(this).val()))) {
    var labelText = $(this).prev('label').text();
    $(this).parent().append('<span class="error">Вы ввели не верный '+labelText+'</span>');
    $(this).addClass('inputError');
    hasError = true;
    }
    }
    });
    if(!hasError) {
    $('form#contact-form input.submit').fadeOut('normal', function() {
    $(this).parent().append('');
    });

     $("#loader").show();
        $.ajax({
            url: "contact.php",
            type: "POST",
            data:  new FormData(this),
            contentType: false,
            cache: false,
            processData:false,
            success: function(data){
        $('form#contact-form').slideUp("fast", function() {
        $(this).before('<div class="success">Спасибо! Ваше письмо было отправлено.</div>');
        $("#loader").hide();
        })
            }           
       });
     
     return false;
    }
 
   });
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question