Skip to content

Instantly share code, notes, and snippets.

@panphora panphora/contact.php forked from libryder/contact.php
Last active Jan 9, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.