|
Posted by Toby A Inkster on 01/18/08 11:05
Gilles Ganault wrote:
> //Check input $_POST[] params: author, subject, body function
function CheckInput2 ()
{
$args = func_get_args();
foreach ($args as $a)
{
if (!isset($_POST[$a])) return false;
if (!strlen($_POST[$a])) return false;
}
}
if (CheckInput2('author', 'subject', 'body'))
{
$to = "support@example.com";
// Please use example.com for examples, unless the owner of
// acme.com has given you permission to use their domain name.
$subject = "[myapp] "
. preg_replace('/[\r\n]/', '', $_POST['subject']);
$body = $_POST['body'];
$headers = preg_replace('/[\r\n]/', '', $_POST['author']) . "\r\n";
if (mail($to, $subject, $body, $headers))
echo "<p>Message successfully sent!</p>";
else
echo "<p>Message delivery failed...</p>";
}
else
{
echo "<p>Check POST parameters!</p>";
}
--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 18 days, 22:10.]
Ham vs Bacon vs Pork
http://tobyinkster.co.uk/blog/2008/01/17/pork-etc/
Navigation:
[Reply to this message]
|