box-o-sand/php-practice/web/html/wikipedia-tutorial/mailing.php

48 lines
1.1 KiB
PHP
Raw Normal View History

2010-12-31 07:57:02 +00:00
<?php
require_once("_head.php");
2010-12-31 18:14:13 +00:00
mkheader("mailing!", "#eee");
2010-12-31 07:57:02 +00:00
?>
<body>
<!-- ======================================================= -->
<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
mail(
2010-12-31 18:14:13 +00:00
$_POST['toaddr'],
$_POST['subject'],
$_POST['message'],
2010-12-31 07:57:02 +00:00
"From: {$_SERVER['PHP_SELF']} <php@localhost>"
);
?><p>Sent!</p><p><a href="<?php echo $_SERVER['PHP_SELF']; ?>">clear this</a></p><?php
} else {
?>
2010-12-31 18:14:13 +00:00
<p>Send an email to somebody!</p>
2010-12-31 07:57:02 +00:00
2010-12-31 18:14:13 +00:00
<form name="send_email" action="" method="POST">
<label class="block" for="toaddr">To:</label>
<input type="text" id="toaddr" name="toaddr" />
2010-12-31 07:57:02 +00:00
2010-12-31 18:14:13 +00:00
<label class="block" for="subject">Subject:</label>
<input type="text" id="subject" name="subject" />
<label class="block" for="message">Message:</label>
<textarea name="message" id="message" rows="10" cols="80"></textarea>
2010-12-31 07:57:02 +00:00
2010-12-31 18:14:13 +00:00
<input class="block" type="submit" name="submit" value="Send" />
2010-12-31 07:57:02 +00:00
</form>
<?php
}
?>
</body>
</html>