OO email-class



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@xxxxxxxxxx');
$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


.



Relevant Pages

  • Re: Replacing a word in a string
    ... >> For the standard library function I do understand why NULL is not ... Why use an empty string for those ... depending on user input ...
    (comp.lang.c)
  • When does input() return an empty string?
    ... I'm filling an array with user input, I want an empty string to be ... ie return key hit twice... ...
    (comp.lang.python)
  • TextMode : Password
    ... characters. ... when i read back the user input, ... empty string. ... How can I get the text box value (entered string) if the TextBox is working ...
    (microsoft.public.dotnet.framework.aspnet)