PHP Menu

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
loupac1
Forum Newbie
Posts: 1
Joined: Mon Nov 15, 2010 2:59 pm

PHP Menu

Post 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.
amplifire
Forum Newbie
Posts: 23
Joined: Thu Jul 22, 2010 1:09 am
Location: India
Contact:

Re: PHP Menu

Post 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
}
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: PHP Menu

Post 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);
Post Reply