Files
.mvn
docs
css
img
js
mail
contact_me.php
scss
vendor
LICENSE
README.md
gulpfile.js
index.html
package-lock.json
package.json
platformQuickStarts
scripts
webgoat-container
webgoat-images
webgoat-integration-tests
webgoat-lessons
webgoat-server
webwolf
.gitignore
.travis.yml
CREATE_RELEASE.MD
LICENSE.txt
README.MD
buildspec.yml
docker-compose-local.yml
docker-compose-postgres.yml
docker-compose.yml
mvn-debug
mvnw
mvnw.cmd
pom.xml
WebGoat/docs/mail/contact_me.php
2019-02-08 14:13:58 +01:00

23 lines
1.1 KiB
PHP

<?php
// Check for empty fields
if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['phone']) || empty($_POST['message']) || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
http_response_code(500);
exit();
}
$name = strip_tags(htmlspecialchars($_POST['name']));
$email = strip_tags(htmlspecialchars($_POST['email']));
$phone = strip_tags(htmlspecialchars($_POST['phone']));
$message = strip_tags(htmlspecialchars($_POST['message']));
// Create the email and send the message
$to = "yourname@yourdomain.com"; // Add your email address inbetween the "" replacing yourname@yourdomain.com - This is where the form will send a message to.
$subject = "Website Contact Form: $name";
$body = "You have received a new message from your website contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email\n\nPhone: $phone\n\nMessage:\n$message";
$header = "From: noreply@yourdomain.com\n"; // This is the email address the generated message will be from. We recommend using something like noreply@yourdomain.com.
$header .= "Reply-To: $email";
if(!mail($to, $subject, $body, $header))
http_response_code(500);
?>