View Full Version : Using classes
zoobie
June 11th, 2002, 10:32
I need to change the below to allow only one email recipient in the 'to' field. I'm not using the cc or bcc in my form. I tried some stuff but it didn't work.
Thanks :rolleyes:
if((count($this->to) + count($this->cc) + count($this->bcc)) < 1)
{
$this->error_handler("You must provide at least one recipient email address");
return false;
}
hohoho
June 11th, 2002, 11:06
i dont think you should use count...count is for arrays
PS: what do u want this script to do ? ;)
nag
June 11th, 2002, 11:07
Here it is your requirement,simply leave the CC and BCC fields in the script.This script will restrict users to enter only one e-mail address..
if((count($this->to) < 1 || (count($this->to) > 1)
{
$this->error_handler("You must provide one recipient e-mail address");
return false;
}
By the way mitja I think e-mail address is also a kind of array????
hohoho
June 11th, 2002, 11:17
no. an array is a value which has more than 1 string ( e.g. $info[0] $info[1] $info[2]
AlieXai
June 11th, 2002, 13:21
mitja is right; an email address is not an array... but you can store email addresses in an array.
If you want to get the length of a string, try using strlen($string) instead of count. Using count() on anything but an array will return "1".
But then again, that could be what you want, since we don't know if $obj->to, $obj->cc and/or $obj->bcc are arrays.
zoobie
June 11th, 2002, 15:43
Well, the more I look at the snippet, the more I realize it just counts. I thought by changing this, it would disallow multi-email addresses but can see now it won't.
It uses AddAddress() to create a 'to' address.
If anyone would like a challenge, the whole script is @ http://geocities.com/zoobie007/formailer.txt
I listed this in the experts exchange for 50 points...and all they replied with was "What are classes and MIME"? :rolleyes:
Give it a shot!
Thanks
Z
Powered by vBulletin® Version 4.1.7 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.