0

I written a code for tkae values of form in HTML and send on e-mail. So, somewhere have a mistake, can you verify this code?

   <form class="form_itself">
        <div>
            <input class="form_input" type="text" name="name" placeholder="Name *">
            <input class="form_input" type="tel" name="tel" placeholder="Contacts *">
            <button id="mybutton" type="submit" class="form_submit upper">Send request</button>
            <div class="order">Callback</div>
        </div>
    </form>

now, pure JS without other frameworks

form = document.getElementById('callBack');
formData = new FormData(form);
request = new XMLHttpRequest();

request.open("POST","sender-form.php",true);
request.setRequestHeader("Content-type","application/x-www-form-urlencoded");
request.send(formData);

and PHP handler, please loot at all this files, where is mistake? code is beta version

<?php
 $name = $_POST['name'];
 $phone  = $_POST['tel'];
 $email="xxxx@email.ru";

 mail($email, $name, $phone);
?>
Cœur
  • 37,241
  • 25
  • 195
  • 267
Drago
  • 19
  • 1
  • 5
  • What is the error you got? – Supun Abesekara Feb 25 '18 at 04:48
  • No, i have no opportunity for test this code, i can only load all of this into wordpress or modx on localhost(PC), but but what I shoud do for test i dont know. In official document of PHP, says that mail() function is not working on local pc – Drago Feb 25 '18 at 10:35
  • In addition I woud ask, some PHP handlers uses new Swift_SmtpTransport function, and I am using a mail() function in PHP, why is difference between two functions and how one of them more better? – Drago Feb 25 '18 at 10:58

0 Answers0