PHP Form sending to different emails based on form values

  • motuhanu
  • Born
  • Born
  • motuhanu
  • Posts: 1

Post 3+ Months Ago

Hi you guys, new here. I looked for some help for this one but can't seem to find what I need. I actually found a post here on the forums that I thought would help me, but I am a complete newbie to PHP so I'm not able to piece everything together!

OK, so I have a contact form that gives different options for the type of inquiry in a select list. I want each of these inquiry options to trigger a different place/email to send the form to. Ok so here's my coding for the form part:

Code: [ Select ]
<form action="formsend.php" method="post" name="form" enctype="text/plain">
Name:
<input type="text" name="name" size="30" maxlength="50" />
<br />
Email:
<input type="text" name="theiremail" size="30" maxlength="50" />
<br />
<br />
Who Are You?
<br />
<input type="radio" name="who" value="spa" /> Spa Representative
<br />
<input type="radio" name="who" value="media" /> Media Representative
<br />
<input type="radio" name="who" value="personal" /> Personal Individual
<br />
<br />
What type of inquiry?
<br />
<select name="typeofinquiry">
<option value="business">Business</option>
<option value="product" selected="selected">Product</option>
<option value="publicrel">Public Relations</option>
<option value="site">Website</option>
<option value="other">Other</option>
</select>
<br />
<textarea rows="5" cols="40" name="question"></textarea>
<br />
<input type="submit" name="submit" value="Send">
<input type="reset" name="reset" value="Clear">
</form>
  1. <form action="formsend.php" method="post" name="form" enctype="text/plain">
  2. Name:
  3. <input type="text" name="name" size="30" maxlength="50" />
  4. <br />
  5. Email:
  6. <input type="text" name="theiremail" size="30" maxlength="50" />
  7. <br />
  8. <br />
  9. Who Are You?
  10. <br />
  11. <input type="radio" name="who" value="spa" /> Spa Representative
  12. <br />
  13. <input type="radio" name="who" value="media" /> Media Representative
  14. <br />
  15. <input type="radio" name="who" value="personal" /> Personal Individual
  16. <br />
  17. <br />
  18. What type of inquiry?
  19. <br />
  20. <select name="typeofinquiry">
  21. <option value="business">Business</option>
  22. <option value="product" selected="selected">Product</option>
  23. <option value="publicrel">Public Relations</option>
  24. <option value="site">Website</option>
  25. <option value="other">Other</option>
  26. </select>
  27. <br />
  28. <textarea rows="5" cols="40" name="question"></textarea>
  29. <br />
  30. <input type="submit" name="submit" value="Send">
  31. <input type="reset" name="reset" value="Clear">
  32. </form>


And then the part that I am stuck on, my formsend.php file:

Code: [ Select ]
<?php

$mailto = $_POST['typeofinquiry'];
 
if($mailto == 'business')
 
{$email = "businessblah@whatever[dot]com";}

elseif($mailto == 'product')

{$email = "productblah@whatever[dot]com";}

elseif($mailto == 'publicrel')

{$email = "publicrelblah@whatever[dot]com";}

elseif($mailto == 'site')

{$email = "siteblah@whatever[dot]com";}

elseif($mailto == 'other')

{$email = "otherblah@whatever[dot]com";};

$subject = "Contact Us";
$name = $_REQUEST['name'] ;
$who = $_REQUEST['who'] ;
$theiremail = $_REQUEST['theiremail'] ;
$question = $_REQUEST['question'] ;
$headers = "Form from: $name, $theiremail";
$sent = mail($mailto, $subject, $question, $headers) ;
if($sent)
{print "Your mail was sent successfully"; }
else
{print "We encountered an error sending your mail"; }

?>
  1. <?php
  2. $mailto = $_POST['typeofinquiry'];
  3.  
  4. if($mailto == 'business')
  5.  
  6. {$email = "businessblah@whatever[dot]com";}
  7. elseif($mailto == 'product')
  8. {$email = "productblah@whatever[dot]com";}
  9. elseif($mailto == 'publicrel')
  10. {$email = "publicrelblah@whatever[dot]com";}
  11. elseif($mailto == 'site')
  12. {$email = "siteblah@whatever[dot]com";}
  13. elseif($mailto == 'other')
  14. {$email = "otherblah@whatever[dot]com";};
  15. $subject = "Contact Us";
  16. $name = $_REQUEST['name'] ;
  17. $who = $_REQUEST['who'] ;
  18. $theiremail = $_REQUEST['theiremail'] ;
  19. $question = $_REQUEST['question'] ;
  20. $headers = "Form from: $name, $theiremail";
  21. $sent = mail($mailto, $subject, $question, $headers) ;
  22. if($sent)
  23. {print "Your mail was sent successfully"; }
  24. else
  25. {print "We encountered an error sending your mail"; }
  26. ?>


Please help me with this ASAP, I have a bit of a deadline, help is much appreciated @_@
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

Post Information

  • Total Posts in this topic: 1 post
  • Users browsing this forum: No registered users and 111 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.