Wywodzę się ze środowiska frontendowego. Z PHP nie mam za dużo do czynienia, jednak dostałem zlecenie na prosty formularz kontaktowy razem backendem oczywiście.
Mam pewien problem, mail jest wysyłany na moją skrzynkę, lecz nie zawiera danych które zostają wypełnione w formularzu (zawiera tylko tekst z body ale bez danych po $). Bardzo proszę Was o pomoc!
Załączam:
HTML
<form action="send.php" method="post" enctype="text/plain"> <div class="form-group"> <input name="name" type="text" class="form-control px-3 py-3" placeholder="Imię i Nazwisko / Firma"> </div> <div class="form-group"> <input name="email" type="text" class="form-control px-3 py-3" placeholder="Email"> </div> <div class="form-group"> <input name="phone" type="text" class="form-control px-3 py-3" placeholder="Telefon"> </div> <div class="form-group"> </div> <div class="form-group"> <input name="submit" type="submit" value="Wyślij" class="btn btn-primary py-3 px-5"> </div> </form>
PHP
<?php require 'phpmailer/PHPMailerAutoload.php'; $submit = $_POST['submit']; $name = $_POST['name']; $phone = $_POST['phone']; $email = $_POST['email']; $message = $_POST['message']; $mail = new PHPMailer(); $mail->Host = "smtp.email.com"; $mail->isSMTP(); $mail->SMTPAuth = true; $mail->Username="moj.email@email.com"; $mail->Password="mojehaslo"; $mail->SMTPSecure = "ssl"; $mail->Port = 465; $mail->Subject = "Formularz kontaktowy"; $mail->isHTML(true); // set body $mail->Body = "From: $name\n Phone: $phone\n E-Mail: $email\n Message:\n $message"; $mail->setFrom('moj.email@email.com', 'Formularz'); $mail->addAddress('moj.email@email.com'); if ($mail->send()) else ?>