Jsheffers Posted May 5, 2009 Report Share Posted May 5, 2009 (edited) Let me explain what I am trying to achieve here. I am doing a site for a real estate company which has a PHP form. I have it setup where you type in your name email, and a message. I also have a drop down menu of choices to pick from. Each category needs to be sent to a different persons email, and all of the messages need to go to the boss. Here is what I have so far. <?php $destination=$_POST['emailCategory']; $name=$_POST['name']; $emailCategory=$_POST['emailCategory']; $email=$_POST['email']; $from ="Website Inquiry"; $phone=$_POST['phone']; $mes=$_POST['mes']; $header="From: $name"; $newMes="Name: $name\n Category: $category\n Email: $email\n Phone: $phone\n Message: $mes\n"; mail($destination,$from,$newMes,"From: Website Inquiry"); mail("test@mac.com",$from,$newMes,"From: Website Inquiry"); header( 'Location: test.html' ); ?> The html looks like this.... Name: Category ...Select a Category Vacation Rentals Yearly Rentals Property Management Work Order Request Other Email: Phone: Message: Any Help would be greatly appreciated Edited May 5, 2009 by Jsheffers Quote Link to comment Share on other sites More sharing options...
falkencreative Posted May 5, 2009 Report Share Posted May 5, 2009 What exactly are you looking for? Is this working? (just glancing over it, it looks like you are approaching it in the correct way) If not, what issue are you having specifically? Quote Link to comment Share on other sites More sharing options...
jlhaslip Posted May 5, 2009 Report Share Posted May 5, 2009 You can reduce some Server load by having the Boss's copy as a BCC header to the mail function. And the default "selected" value might also be an option group instead of a selected value. http://www.w3.org/TR/html401/interact/forms.html#h-17.6 Quote Link to comment Share on other sites More sharing options...
Jsheffers Posted May 6, 2009 Author Report Share Posted May 6, 2009 Ok here is the problem. The OTHER category for example. I want that to go to the bosses email, which in the code above his email is test@mac.com. But they way I have it setup now he gets two emails. One from the emailCategory VAR, which is being fed an email address from the form. Then I have it calling another mail method which goes straight to the boss. If I BCC the boss what should I set the value"" for the categories that only the boss is getting? I hope that made sense, I'm still learning so I apologize if I'm not explaining it properly. Quote Link to comment Share on other sites More sharing options...
jlhaslip Posted May 6, 2009 Report Share Posted May 6, 2009 (edited) Put an IF conditional in there someplace to check for the 'Other' category and don't issue the BCC when the condition is true. Edited May 6, 2009 by jlhaslip Quote Link to comment Share on other sites More sharing options...
Jsheffers Posted May 6, 2009 Author Report Share Posted May 6, 2009 (edited) Can't get the BCC to work... Here is my code... <?php $destination=$_POST['emailCategory']; $name=$_POST['name']; $emailCategory=$_POST['emailCategory']; $email=$_POST['email']; $from ="Website Inquiry"; $phone=$_POST['phone']; $mes=$_POST['mes']; $header="From: $name"; $newMes="Name: $name\n Category: $category\n Email: $email\n Phone: $phone\n Message: $mes\n"; $headers .= 'Bcc: test@mac.com' . "\r\n"; mail($destination,$from,$newMes,$headers,"From: Website Inquiry"); //This line sends you to the thank you page header( 'Location: http://www.test.com/thanks.html' ); ?> Edited May 6, 2009 by Jsheffers Quote Link to comment Share on other sites More sharing options...
Jsheffers Posted May 6, 2009 Author Report Share Posted May 6, 2009 NVM got it working. Had to do double quotes on the email address. Not sure why, but it worked. Now onto the If conditional I have no clue how to do.. Wish me luck.. lol Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.