Reply to Re: [Newbie/PHP 4.4.8] Right way to check POST parameters?

Your name:

Reply:


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/

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация