You are here: [Newbie/PHP 4.4.8] Right way to check POST parameters? « PHP Programming Language « IT news, forums, messages
[Newbie/PHP 4.4.8] Right way to check POST parameters?

Posted by Gilles Ganault on 01/18/08 00:21

Hello

I need customers to be able to send us e-mails from our VB
Classic application using the MSWinsock ActiveX control.

Since there's no easy way to find the address of their SMTP server, I
figured it'd be easier to have it call a PHP script, and send data
with the POST method.

I'm sure there's a cleaner way to check that POST parameters were
correctly sent, but I couldn't find an example:

========
<?php
//Check input $_POST[] params: author, subject, body
function CheckInput(){
return false;

if(isset($_POST)) {
foreach($_POST as $key=>$val) {
if (isset($val)) {
return true;
}
}
}

if CheckInput() {
$to = "support@acme.com";
$subject = "[myapp"] " . $_POST['subject'];
$body = $_POST['body'];
$headers = "From: " . $_POST['author'] . "\r\n"; //. "
//php@svpi.biz\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>");
}

?>
========

Thank you.

 

Navigation:

[Reply to this 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

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