Skip to content

Instantly share code, notes, and snippets.

@jkishner
Created August 23, 2012 18:45
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 jkishner/3440165 to your computer and use it in GitHub Desktop.
Save jkishner/3440165 to your computer and use it in GitHub Desktop.
email fields as per Patrick Rhone's reimagining
<html>
<head>
<link href='http://fonts.googleapis.com/css?family=Quicksand' rel='stylesheet' type='text/css'>
<STYLE type="text/css">
textarea {
font-size:18px;
font-family: 'Quicksand', sans-serif;
outline: none; //see "remove the blue glow" at http://css-tricks.com/textarea-tricks/
}
input.btn {
font-size:18px;
font-family: 'Quicksand', sans-serif;
}
</STYLE>
</head>
<body>
<?php
/* if the "submit" variable does not exist, the form has not been submitted - display initial page */
if (!isset($_POST['submit'])) {
?>
<div align="center">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<textarea name="body" cols="120" rows="25"></textarea><br>
Recipient: <input name="recipient" size="30"><br>
Subject: <input name="subject" size="30"><br>
<input type="submit" name="submit" value="Submit">
</form>
</div>
<?php
}
else
/* if the "submit" variable exists, the form has been submitted - look for and process form data */
// display result
{
$body = $_POST['body'];
$subject = $_POST['subject'];
$recipient = $_POST['recipient'];
$body = stripslashes($body);
$body = rawurlencode($body);
$body = str_replace("?","%3F",$body);
$body = str_replace("&","&amp;",$body);
$subject = stripslashes($subject);
$subject = rawurlencode($subject);
$subject = str_replace("?","%3F",$subject);
$subject = str_replace("&","&amp;",$subject);
//$body = str_replace("%","%25",$body);
echo '<a href="mailto:' . $recipient . '?body=' . $body . '&subject='. $subject . '">Click to email</a>';
}
?>
</body>
</html>
@jkishner
Copy link
Author

Does not currently include line breaks in body of email. Any help welcome!

@jkishner
Copy link
Author

figured it out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment