Skip to content

Instantly share code, notes, and snippets.

@dpilafian dpilafian/perfect.css
Last active Dec 17, 2018

What would you like to do?
Feedback form
/* PERFECT PHP - - MIT or WTFPL (your choice) */
/* PERFECT style */
form.perfect { max-width: 25em; background-color: whitesmoke; color: dimgray; border: 1px solid; border-radius: 2px; padding: 20px; margin: 0px auto 20px auto; }
form.perfect h2 { font-size: 1.2rem; text-align: center; color: white; padding: 0.3em; margin: -20px -20px 20px -20px; clear: none; }
form.perfect fieldset { border: none; padding: 0px; margin: 0px; }
form.perfect label { display: block; text-align: left; }
form.perfect input:not([type=checkbox]):not([type=radio]), form.perfect textarea { width: 100%; max-width: 100%; font-size: 1.2rem; margin: 0px 0px 15px 0px; -webkit-appearance: none; }
form.perfect input[type=checkbox], form.perfect input[type=radio] { font-size: 1.2rem; margin: 0px 0.5em 0.2em 1.5em; }
form.perfect label:last-of-type input { margin-bottom: 20px; }
form.perfect select { font-size: 1.2rem; }
form.perfect textarea { height: 4.1em; }
form.perfect input, form.perfect textarea { box-sizing: border-box; border: 1px solid silver; border-radius: 5px; padding: 0.3em; }
form.perfect p { display: flex; justify-content: space-between; align-items: flex-end; margin: 0px; }
form.perfect p button { font-size: 1.1rem; font-weight: bold; color: white; background-color: dimgray; border: none; border-radius: 0.4em; padding: 0.6em 1.2em; margin-bottom: 0px; cursor: pointer; transition: background-color 0.4s; }
form.perfect p button:hover { background-color: black; }
form.perfect p span { font-size: 0.6rem; color: gray; }
form.perfect p span a { color: gray; background-color: transparent; text-decoration: none; border: none; outline: none; }
/* PERFECT colors */
form.perfect { border-color: seagreen; } /* outer color */
form.perfect h2 { background-color: seagreen; } /* outer color */
form.perfect input, form.perfect textarea { background-color: mintcream; } /* input fields */
<form class=perfect>
<h2>Send us a message</h2>
<textarea name=message placeholder="Enter your message"></textarea>
<input name=name placeholder="Enter your name">
<input name=email type=email placeholder="Enter your email">
<span>Powered by <a href=>PERFECT</a></span>
<button type=submit>Send</button>
<script src=></script>
$('form.perfect').attr({ method: 'post', action: 'perfect.php' });
// v2.1.1 (September 16, 2018) //
// Process a web form to extract the user input and //
// then email the data to a predefined recipient. //
// MIT License or WTFPL (your choice) //
// //
// Configuration settings
$sendFrom = "Form Feedback <>";
$sendTo = "";
$subjectLine = "Feedback Submission";
$thanksUrl = "thanks.html"; //confirmation page
// Build message body from web form input
foreach ($_POST as $field=>$value)
$body .= "$field: $value" . PHP_EOL;
$body .= PHP_EOL . @gethostbyaddr($_SERVER["REMOTE_ADDR"]);
$body = htmlspecialchars($body, ENT_NOQUOTES); //make safe
// Send email and direct browser to confirmation page
mail($sendTo, $subjectLine, $body, "From: $sendFrom");
header("Location: $thanksUrl");
# To make this file runnable:
# $ chmod +x *.sh.command
banner="Publish PERFECT PHP"
projectHome=$(cd $(dirname $0); pwd)
displayIntro() {
cd $projectHome
echo $banner
echo $(echo $banner | sed s/./=/g)
version=$(grep "// v" perfect.php | awk '{ print $2 }')
echo $version
publishWebFiles() {
cd $projectHome
publishWebRoot=$(grep ^DocumentRoot /private/etc/apache2/httpd.conf | awk -F'"' '{ print $2 }')
publish() {
echo "Publishing:"
mkdir -p $publishFolder
cp -v *.css *.php $publishFolder
cp -v perfect.php $publishFolder/archive/perfect-$version.php.txt
cp -v perfect.html $publishFolder/perfect.html.txt
test -w $publishSite && publish
gistReminder() {
echo "Checkin (git push):"
echo " Push commits from the command line using a personal access"
echo " token ( --> Settings) for the password."
ssh -T #ensure command-line access, to fix: $ ssh-add -K ~/.ssh/github_command_line
launchBrowser() {
cd $projectHome
test -w $publishSite && url=http://localhost/
echo "Opening:"
echo $url
sleep 2
open $url
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.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.