The php that makes this possible
You can't see all this using "view source" as all the php is parsed.
That means you only see the results of this PHP (i.e. the HTML), not the PHP code itself.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Email Signup</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="author" content="Francis Booth, fb42.com" />
<style type="text/css">
<!--
* { margin:0; padding:0; font:9px/17px verdana, arial, sans-serif; color:#555; }
body { background: #fff url('bg.gif'); }
h1 { font-size:26px; margin-top:150px; }
p { font-size:12px; margin-bottom:25px; }
form { padding:15px 5px; margin:0 auto; width:220px; }
input { color:#555; padding:2px; border: 1px solid #555; }
input.button { color:#555; padding:1px; background:#bbb; }
#emailSignup { background: #ddd; border-top: 1px solid #bbb; border-bottom: 1px solid #bbb; }
#w3love, h1, p, pre { padding:8px 10px 0 20px; }
#w3love, #w3love * { font-size:9px; text-align:right; }
#w3love a:hover, strong { color:#900; }
pre { font:10px/14px monaco, courier; }
// -->
</style>
</head>
<body>
<?
//////////////////////////////////////////////////
// emailSignup - francisbooth.com - 17 Oct 2005 //
//////////////////////////////////////////////////
$datFile = 'emailSignup.dat'; // file to write to
$recipients = 'spamforbreakfast@fb42.com'; // email recipient list, can be comma delimited
$textInInputField = 'sign the mailing list...'; // text that appears by default in the email entry field
$email = strtolower($_POST[eAddrSend]);
$submit = $_POST[submit];
$regExpEmail = "^([a-z0-9._-]+)@([a-z0-9-])+(\.[a-z0-9-]+)+$"; // regular expression to verify email addresses
$timeOfEntry = strftime("%a %d/%m/%y %H:%M", time()); // date in 'day dd/mm/yy hh:mm' format
if ($submit) {
if (ereg($regExpEmail, $email)) { // check email
if ($file = @fopen($datFile, 'a')) { // open .dat file for appending
$datFileEntry = "$timeOfEntry \remail: $email\r\r";
if (@fwrite($file, $datFileEntry)) {
fclose($file);
// try to send email
$subject = 'Mailing list signup: '.$email;
$body = $email.' has signed the mailing list.';
if (@mail($recipients, $subject, $body)) {
$addressRegistered = true;
$statusReport = 'email added to mailing list';
} else {
$statusReport .= "can't send email";
}
} else {
$statusReport = "script error: can't write to file";
}
} else {
$statusReport = "script error: can't open file";
}
} else {
$statusReport = "invalid email address";
}
if ($statusReport) $statusReportHTML = '<br /><strong>'.$statusReport.'!</strong>';
}
?>
<h1>Email signup form</h1>
<p />PHP script to send a notification email and write the address to a data file.
<br />There's lots of error checking so the user can't really go wrong! ;)
<div id="emailSignup">
<form id="formSend" action="#" target="_self" method="post">
<?
if (!$addressRegistered) {
if (!$email) $email = $textInInputField;
echo '<input type="text" name="eAddrSend" value="'.$email.'"';
echo ' onblur="if (value == \'\') {value = \''. $textInInputField.'\'}"';
echo ' onfocus="if (value == \''. $textInInputField.'\') {value =\'\'}" />';
echo '<input type="submit" name="submit" value="join" class="button" />';
} else {
echo '<input type="text" name="inputSend" value="'.$email.'" readonly="readonly" />';
}
echo $statusReportHTML;
?>
</form>
</div>
<div id="w3love">
<a href="http://validator.w3.org/check/referer">xhtml</a> •
<a href="http://jigsaw.w3.org/css-validator/check/referer">css</a> •
<a href="http://fb42.com/design/">design</a>
</div>
<div id="source">
<h1>The php that makes this possible</h1>
<p />You can't see all this using "view source" as all the php is parsed.
<br />That means you only see the results of this PHP (i.e. the HTML), not the PHP code itself.
<pre><? echo htmlentities(file_get_contents(basename($PHP_SELF))); ?></pre>
</div>
</body>
</html>