RE: multiple foreach loop?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Quoting Aaron Wolski <aaronjw@martekbiz.com>:

> Hi,
> 
> Ok I understand your code...
> 
> 
> How about I error check to ensure that if any of the name/email pairs
> don't have a value to discount their entry?
> 
> For example...
> 
> If the user enters:
> 
> Aaron aaronjw@martekbiz.com
> Rob <blank>
> Bob info@martekibz.com
> <blank> whoever@somewhere.net
> 
> 
> How would I disregard the 2nd and 4th pairs?
> 
> Sorry for bugging.
> 
> Aaron

For validating that any string conforms to some expected pattern....

This will be alot to swallow but it's what you want, glance through the user
added comments, maybe the email validation one is already there.

http://www.php.net/manual/en/function.preg-match.php
or 
http://www.php.net/manual/en/function.ereg-match.php

If you need help, post a new topic in php-general for this one, you'll get
plenty of responses for regex help. ;-)

I hope you don't "understand" the first email, I sent it on accident before
completion.  That was the why you received two.

--Ryan

> -----Original Message-----
> From: Ryan Gallagher [mailto:ryan@studiesabroad.com] 
> Sent: November 20, 2002 2:09 PM
> To: Aaron Wolski
> Subject: Re:  multiple foreach loop?
> 
> Quoting Aaron Wolski <aaronjw@martekbiz.com>:
> 
> > Hi All,
> >  
> > Trying to create a "refer a friend" script.
> >  
> > User enters 10 names and email address of a friend to refer to a site.
> >  
> > The following code SORT of works in that it will send the email, etc..
> > but problem is it duplicates - sends the email out twice to the same
> > email address.
> >  
> > **CODE***
> >  
> > foreach($nameRefered as $referedName) {
> >  
> >             foreach($emailRefered as $referedEmail) {
> >  
> >                         if ($referedEmail != "" && $referedName != "")
> {
> >  
> >                                     <message body here>
> >  
> >                                     /* To send HTML mail, you can set
> > the Content-type header. */
> >                                     $headers = "Return-Path:
> > <$support_email>\r\n";                          
> >                                     $headers .= "MIME-Version:
> 1.0\r\n";
> > 
> >                                     $headers .= "Content-type:
> > text/html; charset=iso-8859-1\r\n";
> >                                     $headers .= "From: $nameReferer
> > <".$emailReferer.">\r\n";
> >  
> >                                     mail ($referedEmail,"Your Order on
> > Rinkrake.com", $message, $headers);
> >  
> >                         }
> >             }
> > }
> >  
> > Any thoughts on why I get the email twice?
> >  
> > Thanks all. Much appreciated!
> >  
> > Aaron 


-- 
Ryan T. Gallagher
ryan@studiesabroad.com
International Studies Abroad
http://www.studiesabroad.com
(512)480-8522



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux