Skip to content

Instantly share code, notes, and snippets.

@weatheredwatcher
Created September 21, 2009 21:42
Show Gist options
  • Save weatheredwatcher/190572 to your computer and use it in GitHub Desktop.
Save weatheredwatcher/190572 to your computer and use it in GitHub Desktop.
<?php
if (isset($_POST['Submit'])){ //this nifty if statement checks to see if there is a submit in the post.
send_mail("youremail@gmail.com", $_POST['subject'], $_POST['message'], $_POST['header']); //if a submit is found, the email is sent
}
else { //is not, the form is displayed
show_form();
}
function show_form(){ //this function shows the form for the email/contact
echo ('<h2>Please fill out this quick form if you wish to contact me:</h2>
<form method="post" action="?id=contact" name="email_me">
<table>
<tr>
<td>From:</td>
<td><input type="text" name="header" id="header" /></td>
</tr>
<tr>
<td>Subject:</td>
<td><input type="text" name="subject" id="message" /></td>
</tr>
<tr>
<td>Message:</td>
<td><input type="text" name="message" id="message" /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="Submit" value="Submit" /></td>
</tr>
</table>
</form>');
}
//The function below sends the email to the right place
function send_mail($to, $subject, $message, $header){
//$header = "From:".$header;
mail($to, $subject, $message, $header);
echo("<h1>Thank you for sending me an email....I'll get back to you as soon as I can </h1>");
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment