Skip to content

Instantly share code, notes, and snippets.

@hansent
Created November 10, 2014 18:20
Show Gist options
  • Save hansent/decc1289291fe7c0561e to your computer and use it in GitHub Desktop.
Save hansent/decc1289291fe7c0561e to your computer and use it in GitHub Desktop.
php intro
thomas@fresklabs.com
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Email Signup</title>
</head>
<body>
<h1> Signup for our email list </h1>
<form method="GET" action="save_email.php">
<input type="text" name="email" placeholder="jd@example.com" >
<input type="submit">
</form>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Thank You</title>
</head>
<body>
<h1>Thank you!</h1>
<?
$email = $_GET['email'] . "\n";
file_put_contents('./emails.txt', $email, FILE_APPEND);
$emails_text = file_get_contents('./emails.txt');
$email_list = explode("\n", $emails_text);
echo "<ul>";
foreach ($email_list as $e_mail) {
echo "<li>$e_mail</li>";
}
for($i=0; $i< count($email_list); $i++) {
$e_mail = $email_list[$i];
echo "<li>$e_mail</li>";
}
echo "</ul>"
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment