Selamlar, bu betik işini görecektir.
<!-- demo_request.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Demo Talep Formu</title>
<link rel="stylesheet" href="
https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
<script src="
https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
</head>
<body>
<div class="container mt-5">
<h2 class="text-center">Demo Talep Formu</h2>
<form id="demoForm">
<div class="form-group">
<label for="name">İsim Soyisim</label>
<input type="text" class="form-control" id="name" name="name" required>
</div>
<div class="form-group">
<label for="email">E-Posta</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
<div class="form-group">
<label for="phone">Telefon</label>
<input type="text" class="form-control" id="phone" name="phone" required>
</div>
<button type="submit" class="btn btn-primary">Talep Gönder</button>
</form>
<div id="response" class="mt-3"></div>
</div>
<script>
$(document).ready(function() {
$('#demoForm').on('submit', function(e) {
e.preventDefault();
$.ajax({
url: 'process_demo.php',
type: 'POST',
data: $(this).serialize(),
success: function(response) {
$('#response').html(response);
}
});
});
});
</script>
</body>
</html>
<!-- process_demo.php -->
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$name = htmlspecialchars($_POST['name']);
$email = htmlspecialchars($_POST['email']);
$phone = htmlspecialchars($_POST['phone']);
// Demo giriş bilgileri oluşturma
$demoUsername = 'demo_user';
$demoPassword = 'demo_pass123';
// PHPMailer ile e-posta gönderimi
$mail = new PHPMailer(true);
try {
$mail->isSMTP();
$mail->Host = 'smtp.example.com'; // SMTP sunucusu
$mail->SMTPAuth = true;
$mail->Username = '
[email protected]'; // SMTP kullanıcı adı
$mail->Password = 'your_password'; // SMTP şifresi
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
// Alıcı bilgileri
$mail->setFrom('
[email protected]', 'Demo Talep');
$mail->addAddress($email, $name);
// İçerik
$mail->isHTML(true);
$mail->Subject = 'Demo Giriş Bilgileriniz';
$mail->Body = "<h3>Merhaba $name,</h3><p>Demo giriş bilgilerinizi aşağıda bulabilirsiniz:</p><ul><li><strong>Kullanıcı Adı:</strong> $demoUsername</li><li><strong>Şifre:</strong> $demoPassword</li></ul><p>Keyifli kullanımlar!</p>";
$mail->send();
echo '<div class="alert alert-success">Demo giriş bilgileri başarıyla gönderildi!</div>';
} catch (Exception $e) {
echo '<div class="alert alert-danger">E-posta gönderilemedi. Hata: ', $mail->ErrorInfo, '</div>';
}
}
?>