|
Posted by Siv Hansen on 09/28/05 21:29
I'm trying to implement an OO-email class. Most of the methods are okay but
one... The one that checks user input.
I've made a function, boolean checkInput(array $input), but I don't know how
to check all array-indexes. I've tried a for-loop, array_search (search for
'', wich I interpret as an empty string), in_array('' - same empty string)
Neither of them pass. The array is deliberately filled out with zero(or
null)-values, but no error message occur (Neither does the success-message)
My code is like this: - from the email class
function checkInput($input){
if(array_search('', $input)){
$this->setError("All the fields must be filled out");
return false;
}
return true;
}
from the main of the script:
$arr=array($sender_name, $sender_email, $subject, $message);
print($myEmail->checkInput($arr));
if($myEmail->checkInput($arr)){
$myEmail->setParam('receiver', 'myEmail@domain.com');
$myEmail -> setParam('sender_email', $sender_email );
$myEmail -> setParam('sender_name', $sender_name);
$myEmail -> setParam('subject', $subject);
$myEmail -> setParam('message', $message);
if($myEmail ->send_email()){
print($myEmail->getMessage()."<br />\n");
print $myEmail->message();
}else{
$myEmail->getError();
}
}else{
$myEmail->getError();
}
}
As you can see, the array $arr contains four indexes, but I'm not able to
check for empty strings (or null-values)
How do I solve this?
Thanks in advance
Siv Hansen
Navigation:
[Reply to this message]
|