Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (isset($_POST['form__submit'])) {
- // переменные, полученные из форм на сайте
- $name = $_POST["name"];
- $phone = $_POST["phone"];
- $email = $_POST["email"];
- require_once 'PHPMailer/PHPMailerAutoload.php';
- $mail = new PHPMailer();
- $mail->CharSet = 'utf-8';
- $email_body = "";
- $email_body = $email_body . "<p>Имя:</p><h2>".$name."</h2><p>Телефон:</p><h2>".$phone."</h2><p>Email:</p><h2>".$email."</h2>";
- if (!empty($_FILES['file'])) {
- $mail->addAttachment($_FILES['file']['tmp_name'], $_FILES['file']['name']);
- }
- $mail->Subject = 'Новая заявка с лендинга';
- $mail->MsgHTML($email_body);
- if(!$mail->send()) {
- echo 'Message could not be sent.';
- echo 'Mailer Error: ' . $mail->ErrorInfo;
- exit;
- } else {
- $redirect_url = '/thanks.html';
- header("Location: http://".$_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . $redirect_url);
- unset($_POST);
- exit;
- }
- }
- ?>
- <!DOCTYPE html>
- <html lang="ru">
- <head>
- <title></title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
- </head>
- <body>
- <form action="" method="post" class="myform">
- <input type="text" placeholder="Ваше имя:" class="input" name="name">
- <button type="submit" class="blue__btn" name="form__submit">Отправить</button>
- </form>
- </body>
Advertisement
Add Comment
Please, Sign In to add comment