Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7944007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:26:07+00:00 2026-06-04T00:26:07+00:00

Hi Everyone, I am trying to post a form using php mail() function to

  • 0

Hi Everyone,

I am trying to post a form using php mail() function to the person selected in a from a option drop down box.

My drop down box shows

<label for="contact">Job Contact:*</label>

<select id='contact' name='contact'>
<option value='' selected='selected'>Please select</option>
<option value='name1'>Name2</option>
<option value='name2'>Name1</option>
</select> 

Which I get the value.

$contact =  $_POST['contact'];

Compare with users

switch ($contact) {

            case "name1":
            $to         = "name1@example.co.uk";
            break;
            case "name2":
            $to         = "name2@example.co.uk";
            break;

        }

mail($to, …, …, …);

I can not see why switch does not work?

if i use $to on its own the form sends.

Any ideas would be a great help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T00:26:08+00:00Added an answer on June 4, 2026 at 12:26 am

    There are several points of failure here;

    You could try expanding your switch (for debugging purposes only) to do something like this:

    switch ($contact) {
    
                case "name1":
                $to         = "name1@example.co.uk";
                break;
                case "name2":
                $to         = "name2@example.co.uk";
                break;
                default:
                var_dump($contact);
                exit();
    
            }
    

    This will force your switch to handle the contents of $contact if it desn’t match any of the switches.

    Secondly, try to make sure that $to actually contains a value.

    Do this by adding ‘var_dump($to); right before the mail() function.

    This is basic debugging – and I suspect that one of those will tell you where the error is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

everyone! i'm trying to create ExtJs form and post some data to my php
Hi everyone Im trying to post some data to a php script using AppMancer
I am trying to post on my friend's wall using PHP SDK of FB.
Hello everyone I'm trying to improve my Java skills by solving some problems from
Hello everyone I've been trying to put some objects in an ASP.NET list box
Hello everyone I been trying get php uploader working but having a lot of
Hello everyone this is my first post on stack overflow.com I am trying to
I'm trying to post a note using Facebook Graph API. I would like to
Hi Everyone (this is my first post), I am trying to figure a way
Possible Duplicate: sending post data from Iphone Hello everyone, I'm a new member of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.