Change $mailTo variable based on select input value (array)

Posted by Dirty Bird Design on Stack Overflow See other posts from Stack Overflow or by Dirty Bird Design
Published on 2014-06-11T03:06:59Z Indexed on 2014/06/11 3:25 UTC
Read the original article Hit count: 139

Filed under:
|

I have the following select list:

<form action="mail.php" method="POST">
    <select name="foo" id="foo">
        <option value="sales">Sales</option>
        <option value="salesAssist">Sales Assist</option>
        <option value="billing">Billing</option>
        <option value="billingAssist">Billing Assist</option>
    </select>
</form>

I need to route the $mailTo variable depending on which option they select, Sales and Sales Assist go to [email protected], while Billing and Billing Assist go to [email protected]

PHP pseudeo code!

<? php 
   $_POST['foo'] if inArray(sales, salesAssist) foo="[email protected]";
    else if inArray(billing, billingAssist) foo="[email protected]";
   mailTo="foo"
?>

I know there is nothing correct about the above, but you can see what I am trying to do, change a variable's value based on the selected value. I don't want to do this with JS, would rather learn more PHP here. Thank you.

© Stack Overflow or respective owner

Related posts about php

Related posts about arrays