Forum Moderators: coopster
If there were only two or three, it'd be easy:
if ($list = "xyz")
{
$email = "xyz@domain.com";
}
else ($list = "abc")
{
$email = "abc@domain.com";
}
and I think that's the code but I'm typing from memory since the actual file's at home.
Anyway, once it gets about three or four, the whole if/elseif/else combination becomes top-heavy and falls through. I went back and forth through my PHP books, and although it *seems* (in pseudo code) that I could do what I want with a combination of match, find, or replace, most of the books seem to figure that I'll just go straight into doing a SQL database. Since this is all I want to do (so far) it seems like overkill to pay for the SQL db on my hosting service, if it's possible to make the list, have PHP select the $email value that corresponds to the $list value carried over, and then use that $email value as the recipient.
Uh...if it's possible, I mean. Is it?
(Thanks again!)
In the form, on first page, the form includes a line for hidden with name of 'list' and value="<?php echo $list?>". Then, on the proc page, here's the pseudocode for what I'm trying to do.
where $list = "abc" then $email = "asdf@domain1.com"
where $list = "xyz" then $email = "qwer@domain2.net"
where $list = "def" then $email = "xcvb@domain3.org"
(etc, 45 times!)
compare $list (from form/url) to $list values above
get $email value where $list = $list
set $email = $to
(and then the rest of the formmail setup follows)
Does that make more sense?
switch($list){
case 'abc':
$email = 'asdf@domain1.com";
break;
case 'dsf':
$email = 'dsf2@domain2.com";
break;
...
}
HelenDev's got the best long-term solution to this I think. Format a text file and read up on your file read/write functions. It will probably much easier to work with in the long run (and less maintenance).
HTH,
Conor
How come your elseif statement doesn't work? I'm not aware that there is a limit to how many times you can do that (correct me if I'm wrong anyone!) Perhaps there is a syntax error somewhere? Or does it just take too long?
case 'maryta':
$email = 'mtaylor@domain.com";
break;
so the 'mtaylor... is now "mtaylor...
Then I started getting errors (I guess we're working our way down the page, eh?) at the
$to = $email;
So I tried "$email" and then switched them so it's $email = $to; at which point I started getting parse errors on line 138...which is blank. The line immediately preceeding it is the mail() line.
Ahem. Giving up temporarily, I went back to the if/elseif list I'd originally tried, made sure it was if/elseif/elseif/elseif (I'd missed one), and loaded that up to test. Now it accepts the form...and never delivers the mail.
Ah. Hm. About this text file. Can someone direct me to a page that explains how to do that? (Like I said above, paying the extra $36 a year for SQL option on my hosting service seems ridiculous if there's a simpler way to do this one blasted thing...)
Thx for your help, all.
*runs around in circles while scaring the beagle*
Thanks, everyone, for suggestions & letting me puzzle it out here. Much, MUCH appreciated - I've been struggling with this for a week with the various emailer codes, and I guess sometimes the simplest really is the best.
Thanks again!
- Sol