Нужно сделать так чтобы кнопка выполняла 2 действия сразу. Отправляла данные из формы и переносила на другую страницу
Выше все описал.
<form action="mailer/smart.php" method="POST">
<div style="margin: 50px 0px;" class="form">
<h1 style="overflow: hidden;" >Make a Donation Now</h1>
<hr>
<span>Had strictly mrs handsome mistaken cheerful. We it so if resolution invitation remarkably unpleasant conviction. As into ye then form.</span>
<br><br>
<select id="sel" class="form-select form-select-lg mb-3" aria-label=".form-select-lg example">
<option class="sel0">Выберите какую информацию оставите</option>
<option class="sel1">Имя</option>
<option class="sel2">Почта</option>
<option class="sel3">Коментарий</option>
<option class="sel4">Имя, Почта, Комментарий</option>
</select>
<div id="result"></div>
<!-- <button style="margin-top: 20px; margin-bottom: 20px;" type="submit" class="btn form-btn btn-outline-light" value="Отправить">Отправить информацию</button> -->
<button style="margin-top: 20px; margin-bottom: 20px;" type="submit" class="btn form-btn btn-outline-light" onclick="window.location.href='poz.html'" value="Отправить">Пожертвовать</button>
<br>
</div>
</form>
<script>
$(document).ready(function(){
$('#sel').change(function(){
if ($('#sel option:selected').hasClass("sel1")) {
$("#result").html("<label for='exampleInputName' class='form-label'>Имя</label><input placeholder='Jame' name='biznes_name' type='name' class='form-control' id='exampleInputPassword1'>");
} else if ($("#sel option:selected").hasClass("sel2")) {
$("#result").html("<label for='exampleInputEmail' class='form-label'>Почта</label><input placeholder='[email protected]' name='biznes_email' type='email' class='form-control' id='exampleInputPassword1'>");
} else if ($('#sel option:selected').hasClass("sel3")) {
$("#result").html("<label for='exampleInputText' class='form-label'>Ваш коментарий</label><textarea placeholder='коментарий' name='biznes_text' style='width: 100%;'></textarea>");
} else if ($('#sel option:selected').hasClass("sel4")) {
$("#result").html("<label for='exampleInputName' class='form-label'>Имя</label><input placeholder='Jame' name='biznes_name' type='name' class='form-control' id='exampleInputPassword1'><label for='exampleInputEmail' class='form-label'>Эл.почта</label><input placeholder='[email protected]' name='biznes_email' type='email' class='form-control' id='exampleInputPassword1'><label for='exampleInputText' class='form-label'>Ваш коментарий</label><textarea placeholder='коментарий' name='biznes_text' style='width: 100%;'></textarea>");
}
});
});
</script>
<?php
$name = $_POST['biznes_name'];
$email = $_POST['biznes_email'];
$comment = $_POST['biznes_text'];
require_once('phpmailer/PHPMailerAutoload.php');
$mail = new PHPMailer;
$mail->CharSet = 'utf-8';
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.mail.ru'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // Наш логин
$mail->Password = 'somepassword'; // Наш пароль от ящика
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->setFrom('[email protected]', 'Донат'); // От кого письмо
$mail->addAddress('[email protected] '); // Add a recipient
//$mail->addAddress('[email protected]'); // Name is optional
//$mail->addReplyTo('[email protected]', 'Information');
//$mail->addCC('[email protected]');
//$mail->addBCC('[email protected]');
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Пожертвование';
$mail->Body = '
Пользователь оставил свои данные <br>
Почта: ' . $email . '
Имя: ' . $name . ' <br>
Комментарий: ' . $name . ' <br>
' '';
$mail->AltBody = 'Небольшие технические неадекватки';
if(!$mail->send()) {
return false;
} else {
return true;
}
?>