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 6776645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:03:13+00:00 2026-05-26T16:03:13+00:00

I’m trying all day and can’t get this to work. I have four input

  • 0

I’m trying all day and can’t get this to work.

I have four input type="radio" name="sector" value="value1" but can’t get this to work.

function emailtotest($to) {
    if (strip_tags($_POST['sector']) == 'value1') {
        $to .= 'email1@domain.com';
    } elseif (strip_tags($_POST['sector']) == 'value2') {
        $to .= 'email2@domain.com';
    } elseif (strip_tags($_POST['sector']) == 'value3') {
        $to .= 'email3@domain.com';
    } elseif (strip_tags($_POST['sector']) == 'value4') {
        $to .= 'email4@domain.com';
    } else {
        $to .= 'email5@domain.com';
    }
    return $to;
}

I already test the sendmail.php and it’s working perfectly if I declare $to = email@dominio.com, but with the radio inputs won’t work.

Any help please?

The form code:

    <form id="contactForm" action="sendmail.php" method="post">
    <p>
        <label for="nome">Nome</label><br>
        <input type="text" id="nome" name="nome" required="required" class="input_full">
    </p>
    <p>
        <label for="tel">Telefone</label><br>
        <input type="tel" id="tel" name="tel" required="required" class="input_full">
    </p>
    <p>
        <label for="email">E-mail</label><br>
        <input type="email" id="email" name="email" placeholder="nome@exemplo.com" required="required" class="input_full">
    </p>
    <p>
        <label for="radio_1">
            <input type="radio" id="radio_1" name="sector" value="value1">
            Comercial / Marketing
        </label>
        <label for="radio_2">
            <input type="radio" id="radio_2" name="sector" value="value2">
            Produto / Manutenção
        </label>
        <label for="radio_3">
            <input type="radio" id="radio_3" name="sector" value="value3">
            Financeiro
        </label>
        <label for="radio_4">
            <input type="radio" id="radio_4" name="sector" value="value4">
            Administração
        </label>
    </p>
    <p>
        <label for="mensagem">Mensagem</label><br>
        <textarea id="mensagem" name="mensagem" rows="5" placeholder="Escreva aqui sua mensagem." required="required" class="input_full"></textarea>
    </p>
    <p>
        <input type="submit" value="Enviar &rarr;">
    </p>
</form>
  • 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-05-26T16:03:14+00:00Added an answer on May 26, 2026 at 4:03 pm

    Hm HTML part looks ok but try to correct this:

    function emailtotest($to) {
    if (strip_tags($_POST['sector']) == 'value1') {
        $to = 'email1@domain.com';
    } elseif (strip_tags($_POST['sector']) == 'value2') {
        $to = 'email2@domain.com';
    } elseif (strip_tags($_POST['sector']) == 'value3') {
        $to = 'email3@domain.com';
    } elseif (strip_tags($_POST['sector']) == 'value4') {
        $to = 'email4@domain.com';
    } else {
        $to = 'email5@domain.com';
    }
    return $to;
    

    }

    So instead of $to .= “email..”; use just $to = “email”; so without dot before =

    Why?

    Because if you use .= it means that you add a value to existing value. So example if $to already contains this value: email@email.com and then you use $to.= “email1@email.com”; then $to will contains BOTH values and will look like this: email@email.comemail1@email.com
    Which is not really OK. The other (same) solution is also this:

    function emailtotest($to) {
    if (strip_tags($_POST['sector']) == 'value1') {
    return 'email1@domain.com';
    } elseif (strip_tags($_POST['sector']) == 'value2') {
    return 'email2@domain.com';
    } elseif (strip_tags($_POST['sector']) == 'value3') {
    return 'email3@domain.com';
    } elseif (strip_tags($_POST['sector']) == 'value4') {
    return 'email4@domain.com';
    } else {
    return 'email5@domain.com';
    }
    }
    

    That’s one thing and another try NOT to using $_POST in functions even it’s global. Get the value from $_POST example:

    $which = trim(strip_tags($_POST['sector'])); //get your checkbox value
    

    And then call a function and take $which into function like:

    $to_email = emailtotest($which); //call a function and take $which - value1, value2...
    mail($to_email, "subject", "email txt"); //then send a mail to $to_email
    
    function emailtotest($value){
    if($value=='value1'){
    return 'email1@domain.com';
    }
    else if ($value=='value2'){
    return 'email2@domain.com'
    .....
    ....
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I am trying to loop through a bunch of documents I have to put
I have some data like this: 1 2 3 4 5 9 2 6
I am trying to understand how to use SyndicationItem to display feed which is

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.