Hallo zusammen,
ich bin noch nicht so fit mit PHP und möchte Euch bitten den folgenden Code für mich zu checken. Es geht mir darum, wenn ich in Zeile 5 und 10 des PHP-Files echte E-Mailadressen eingebe, sind die dann sicher und vor Spam geschützt.?
HTML: HTML
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Kontakt</title>
</head>
<body>
<div class="contact-title">
<h1>Kontaktformular</h1>
<h2>Hier können Sie uns schreiben!</h2>
</div>
<div class="contact-form">
<form id="contact-form" method="post" action="contact-form-handler.php">
<input name="name" type="text" class="form-control" placeholder="Ihr Name" required>
<br>
<input name="email" type="email" class="form-control" placeholder="Ihre E-Mailadresse" required>
<br>
<textarea name="message" class="form-control" placeholder="Ihr Text" rows="4" required></textarea>
<br>
<input type="submit" class="form-control submit" value="ABSENDEN">
</form>
</div>
</body>
</html>
Alles anzeigen
Code: CSS
*{
margin: 0;
padding: 0;
}
body{
text-align: center;
background-color: blue;
background-size: cover;
background-position: center;
font-family: sans-serif;
}
.contact-title{
margin-top: 100px;
color: #fff;
text-transform: uppercase;
transition: all 4s ease-in-out;
}
.contact-title h1{
font-size: 2em;
line-height: 1em;
margin-bottom: 0.5em;
}
.contact-title h2{
font-size: 1em;
}
form{
margin-top: 2.5em;
transition: all 4s ease-in-out;
}
.form-control{
width: 600px;
background:transparent;
color: #000;
border: none;
outline: none;
border-bottom: 2px solid grey;
color: #fff;
font-size: 1em;
margin-bottom: 0.9em;
}
input{
height: 2.5em;
}
form .submit{
background: #ff5722;
border-color: transparent;
color: #fff;
font-size: 1.25em;
font-weight: bold;
letter-spacing: 2px;
height: 2.5em;
margin-top: 1.25em;
}
form .submit:hover{
background-color: #c95c41;
cursor: pointer;
}
Alles anzeigen
PHP: PHP
<?php
$name = $_POST['name'];
$visitor_email = $_POST['email'];
$message = $_POST['message'];
$email_from = 'test@abc.de';
$email_subject = "Neues E-Mail von Deiner Webseite";
$email_body = "User Name: $name.\n".
"Email: $visitor_email.\n".
"User Anfrage: $message.\n";
$to = "test@abc.de";
$headers = "Von: $email_from \r\n";
$headers .= "Antwort an: $visitor_email \r\n";
mail($to,$email_subject,$email_body,$headers);
header("Location: index.html");
?>
Alles anzeigen