Hardware Reference
In-Depth Information
8
<?php
/*
Mail sender
Context: PHP
Sends an email if sensorValue is above a threshold value.
*/
// form the message:
$to = "you@example.com";
$subject = "the cat";
$message = "The cat is on the mat at http://www.example.com/catcam.";
$from = "cat@example.com";
// send the mail:
mail($to, $subject, $message, "From: $from");
// reply to processing:
echo "TO: " .$to;
echo "\nFROM: " .$from;
echo "\nSUBJECT:" .$subject;
echo "\n\n" .$message . "\n\n";
?>
8 You'll need to change these email
addresses.
!
Now that you're sending emails from
a program, you need to be very careful
about how often it happens. You really don't
want 10,000 messages in your inbox because
you accidentally called the mail command in a
repeating loop.
Now you're getting somewhere! You're able to send
mail triggered by a physical event—the cat sitting on
the mat. This is a good moment to stop and celebrate
your achievement and pet the cat. In the next section,
you're going to use a webcam to make your cat Internet-
famous.
X
Making a Web Page for the
Cat Cam
8
Next, you need a web page for the cat cam. Take
a picture of your cat and upload the image to the
directory containing your script with the filename
catcam.jpg. Once you know the image is there and visible,
frame it with a web page in the same directory, called
index.html. Here is a bare-bones page that will auto-
matically refresh itself in the user's browser every five
seconds, as indicated by the meta tag in the head of the
document. Feel free to make the page as detailed as you
want, but keep the meta tag in place.
<html>
<head>
<title>Cat Cam</title>
<meta http-equiv="refresh" content="5">
</head>
<body>
<center>
<h2>Cat Cam</h2>
<img src="catcam.jpg">
</center>
</body>
</html>
 
Search WWH ::




Custom Search