Skip to content

Instantly share code, notes, and snippets.

@rushdimohamed09
Created March 19, 2016 21:08
Show Gist options
  • Save rushdimohamed09/91751227ffdc1b3cd886 to your computer and use it in GitHub Desktop.
Save rushdimohamed09/91751227ffdc1b3cd886 to your computer and use it in GitHub Desktop.
<?php
$action=$_REQUEST['action'];
if ($action=="") /* display the contact form */
{
?>
<form action="contact.php" method="POST" enctype="multipart/form-data">
<input type="hidden" name="action" value="submit">
Your name:<br>
<input name="name" type="text" value="" size="30"/><br>
Your email:<br>
<input name="email" type="text" value="" size="30"/><br>
Your message:<br>
<textarea name="message" rows="7" cols="30"></textarea><br>
<input type="submit" name="submit" value="Send email"/>
</form>
<?php
}
else /* send the submitted data */
{
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$message=$_REQUEST['message'];
if (($name=="")||($email=="")||($message==""))
{
echo "All fields are required, please fill <a href=\'\'>the form</a> again.";
}
else{
$from="From:". $name."".$email."\r\nReturn-path: ".$email;
$subject="Message sent using your contact form";
mail("youremail@yoursite.com", $subject, $message, $from);
echo "Email sent!";
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment