Created
November 10, 2014 18:20
-
-
Save hansent/decc1289291fe7c0561e to your computer and use it in GitHub Desktop.
php intro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
thomas@fresklabs.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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