Page 1 of 1

PHP Menu

Posted: Mon Nov 15, 2010 3:08 pm
by loupac1
Im having trouble figuring out how this is done. I need to create a menu that will take a form and distribute it to 3 different email addresses depending on the state selected in the drop down. Example: A customer wants more information on a product. My company has sales people in 3 differnt areas in the US. The form has to contain Name, Email Address and State. Depending on the state selected the email needs to be distributed to 1 of the 3 sales people. If someone Selects OHIO then the email with go to salesman@website.com. If they select California, the email needs to go to salesman2@website.com. ANY help would be greatly appreciated. Thank you in advance. If I can word this any better or if you need more information from me PLEASE let me know. Thanks.

Re: PHP Menu

Posted: Mon Nov 22, 2010 12:19 pm
by amplifire
From what i understand, you want to automate the code such that if somebody selects one particular city then the program should logically select the email id petaining to that city's executive.
California --> salesman1@webmaster.com
Ohio --> salesman2@webmaster.com
New York --> salesman@webmaster.com

For this you can easily set if statement or switch case statement. Go for the tutorials on Google.
Ex.
If(City==California) {
email=salesman1@webmaster.com
}

Re: PHP Menu

Posted: Mon Nov 22, 2010 1:25 pm
by califdon
I assume you know how to code the form and the action script to retrieve the POST variables. In case you don't, you must start there. All of this can be learned from the many online tutorials, such as at http://w3schools.org, http://www.tizag.com/ and, of course, the PHP manual http://us2.php.net/manual/en/langref.php.

Something like:

Code: Select all

switch ($state) {
   case 'CA':
      $to='salesman1@webmaster.com';
      break;
   case 'OH':
      $to='salesman2@webmaster.com';
      break;
   case 'NY':
      $to='salesman@webmaster.com';
}

mail($to, $subj, $message, $hdrs);