| Current Path : /home/wirbesti/unwaehlbar.ch/ |
| Current File : /home/wirbesti/unwaehlbar.ch/contact.php |
<?php
if (!isset($_SESSION)) {
session_start();
}
?>
<!Doctype html>
<html lang="de">
<title>Kontaktformular</title>
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-T51P2G7FB6"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'G-T51P2G7FB6');
</script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.6.0/dist/umd/popper.min.js"
integrity="sha384-KsvD1yqQ1/1+IA7gi3P0tyJcT3vR+NdBTt13hSJ2lnve8agRGXTTyNaBYmCR/Nwi" crossorigin="anonymous">
</script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/js/bootstrap.min.js"
integrity="sha384-nsg8ua9HAw1y0W1btsyWgBklPnCUAFLuTMS2G72MMONqmOymq585AcH49TLBQObG" crossorigin="anonymous">
</script>
<!-- <link href="./css/fontawesome.css" rel="stylesheet"> -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.2/css/all.css"
integrity="sha384-vSIIfh2YWi9wW0r9iZe7RJPrKwp6bG+s9QZMoITbCckVJqGCCRhc+ccxNcdpHuYu" crossorigin="anonymous">
<link href="css/site.css" type="text/css" rel="stylesheet">
<script src="./libs/jquery-3.5.1.min.js"></script>
<script src="./libs/site.js"></script>
<link rel="stylesheet" type="text/css" href="css/contact.css">
<style>
.dropshadowimgsmall {
box-shadow: 2px 2px 2px #999;
}
</style>
</head>
<body>
<?php require_once 'menu.php'; ?>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$captchaResult = $_POST['captchaResult'];
$captcha = $_POST['captcha'];
if ($captcha == $captchaResult) {
$to = 'contact@unwaehlbar.ch';
$subject = 'Contact Form Message';
$headers = 'From: ' . $email . "\r\n" .
'Reply-To: ' . $email . "\r\n" .
'X-Mailer: PHP/' . phpversion();
if (mail($to, $subject, $message, $headers)) {
echo "Email sent successfully!";
} else {
echo "Failed to send the email!";
}
} else {
echo 'Captcha result is wrong!';
}
}
$num1 = rand(1, 9); // Generate Random number 1
$num2 = rand(1, 9); // Generate Random number 2
?>
<div id="contact-form-container" class="container">
<form id="contact-form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
Name: <input type="text" name="name" required><br>
E-Mail: <input type="email" name="email" required><br>
Nachricht: <textarea name="message" required></textarea><br>
Captcha: <?php echo $num1 . ' + ' . $num2 . ' = '; ?>
<input name="captchaResult" type="text"/><br>
<input type="hidden" name="captcha" value="<?php echo $num1 + $num2; ?>"/>
<input type="submit" value="Abschicken">
</form>
</div>
</body>
</html>