Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@panphora
Forked from libryder/contact.php
Last active January 9, 2019 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save panphora/34e675a6246e196a82230715b87729ed to your computer and use it in GitHub Desktop.
Save panphora/34e675a6246e196a82230715b87729ed to your computer and use it in GitHub Desktop.
Super simple PHP contact form in one file
<html>
<head>
<title>Contact Us</title>
</head>
<body>
<?php
if ($_POST['message']) {
$message = $_POST['message'];
$email = $_POST['email'];
$name = $_POST['name'];
$headers = "From: ".$name."<".$email.">";
mail('you@example.com', "Contact from My Website", $message, $headers)
echo "Thank you for contacting us!<br /><br />";
}
?>
<form action="" method="post">
<div>
<div><label for="name">Name:</label></div>
<input id="name" type="text" name="name" />
</div>
<div>
<div><label for="email">Email:</label></div>
<input id="email" type="email" name="email" />
</div>
<div>
<div><label for="message">Message:</label></div>
<textarea id="message" name="message" cols="50" rows="5"></textarea>
</div>
<div>
<input type="submit" value="Submit">
</div>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment