|
Posted by Jerry Stuckle on 11/20/07 02:39
Bill H wrote:
> I wrote a PHP script that the user decides who they want to send the email
> to based on the selection from a "dropdown" box. The essential part of the
> script that I'm having problems with is:
>
> <?php
>
> /* Pre-defined script variables. */
> $eol = "\n";
> $mailto = 'me@mycorp.net';
> $mailfrom = 'webserver@mycorp.net';
> $subject = 'Contact Us Request';
>
> /* Initialize a clean array to replace $_POST with clean data */
> $etype = $_POST['etype'];
> $errmsg = 'etype-: '.$etype.' | Case value-: ';
>
> /* Define the mailto address
> switch ($etype) {
> case 0:
> $mailto = 'sales@mycorp.net';
> $errmsg .= '0';
> break;
> case 1:
> $mailto = 'support@mycorp.net';
> $errmsg .= '1';
> break;
> case 2:
> $mailto = 'webmaster@mycorp.net';
> $errmsg .= '2';
> break;
> case 3:
> $mailto = 'myacct@mycorp.net';
> $errmsg .= '3';
> break;
> default:
> $mailto = 'me@mycorp.net';
> $errmsg .= 'default';
> }
> .
> .
> builds an email and sends it to myself.
> ?>
>
> The email shows up at the "me" address instead of the "myacct" address. The
> problem is the email shows "etype-: 3 | Case value-: ". This indicates
> that the switch didn't work at all. Can anyone tell me why?
>
> Thanks,
>
> Bill
>
>
>
Bill,
Try
case '0':
case '1':
etc
Or, when I know it's a numeric value, I use:
$etype= isset($_POST['etype']) ? intval($_POST['etype']) ? 0;
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|