addContact.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>addContact.html</title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<link rel = "stylesheet"
type = "text/css"
href = "contact.css" />
</head>
<body>
<?php
//read data from form
$lName = $_REQUEST["lName"];
$fName = $_REQUEST["fName"];
$email = $_REQUEST["email"];
$phone = $_REQUEST["phone"];
//print form results to user
print <<< HERE
<h1>Thanks!</h1>
<p>
Your spam will be arriving shortly.
</p>
<p>
first name: $fName <br />
last name: $lName <br />
email: $email <br />
phone: $phone
</p>
HERE;
//generate output for text file
$output = <<< HERE
first: $fName
last: $lName
email: $email
phone: $phone
HERE;
//open file for output
$fp = fopen("contacts.txt", "a");
//write to the file
fwrite($fp, $output);
fclose($fp);
?>
</body>
</html>