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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:21:04+00:00 2026-06-13T16:21:04+00:00

I have a mailform that I use. In a new usage I have added

  • 0

I have a mailform that I use. In a new usage I have added 2 checkboxes. I would like to be able to send mail to differing addresses based on the check boxes.
EX: if “box1 checked mail to xx, if box 2 checked mail to xx, else mail to both. The code That I use to mail is:

<?

/************************
* Variables you can change
*************************/

$mailto = "";
$cc = "";
$bcc = "";
$subject = "contact";
$vname = "Enquiry";


/************************
* do not modify anything below unless you know PHP/HTML/XHTML
*************************/
/* my trial adjustment for check boxes
*/


$email = $_POST['email'];

function validateEmail($email)
{
   if(eregi('^[a-zA-Z0-9._-]+@[a-zA-Z0-9-]+\.[a-zA-Z]{2,4}(\.[a-zA-Z]{2,3})?(\.[a-zA-Z]{2,3})?$', $email))
      return true;
   else
      return false;
}


if((strlen($_POST['name']) < 1 ) || (strlen($email) < 1 ) || (strlen($_POST['message']) < 1 ) || validateEmail($email) == FALSE){
    $emailerror .= '';

    if(strlen($_POST['name']) < 1 ){
        $emailerror .= '<li>Enter name</li>';
    }

    if(strlen($email) < 1 ){
        $emailerror .= '<li>Enter email</li>';
    }

    if(validateEmail($email) == FALSE) {
        $emailerror .= '<li>Enter valid email</li>';
    }

    if(strlen($_POST['message']) < 1 ){
        $emailerror .= '<li>Enter message</li>';
    }

} else {

    $emailerror .= "Your email has been sent successfully";



    // NOW SEND THE ENQUIRY

    $timestamp = date("F j, Y, g:ia");

    $messageproper ="\n\n" .
        "Name: " .
        ucwords($_POST['name']) .
        "\n" .
        "Email: " .
        ucwords($email) .
        "\n" .
        "Telephone Contact: " .
        ucwords($_POST['tel']) .
        "\n" .
        "Company: " .
        ucwords($_POST['company']) .
        "\n" .
        "Comments: " .
        $_POST['message'] .
        "\n" .
        "\n\n" ;

        $messageproper = trim(stripslashes($messageproper));
        mail($mailto, $subject, $messageproper, "From: \"$vname\" <".$_POST['e_mail'].">\nReply-To: \"".ucwords($_POST['first_name'])."\" <".$_POST['e_mail'].">\nX-Mailer: PHP/" . phpversion() );

}
?>

<div id='emailerror'>
    <ul>
        <? echo $emailerror; ?>
    </ul>
</div>

The check box code:

   <label>MailPersonA</label>
    <input type="checkbox" name="A" value="checkbox" id="A" />
   <label>MailPersonB</label>
      <input type="checkbox" name="B" value="checkbox" id="B" />

Any help will be appreciated.

  • 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-13T16:21:05+00:00Added an answer on June 13, 2026 at 4:21 pm

    You probably want to:

    • use radio inputs instead of checkboxes, to make sure exactly one is chosen
    • name the radios the same
    • give them different values

    So your HTML would be

    <label>MailPersonA</label>
    <input type="radio" name="toaddress" value="person1@wherever.com" id="A" />
    <label>MailPersonB</label>
    <input type="radio" name="toaddress" value="person2@wherever.com" id="B" />
    

    Now $_POST['toaddress'] will contain the destination email address.

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

Sidebar

Related Questions

I have a GridView, radGvA133s, on my main form, MainForm. I would like to
I have a form MainForm which is a Windows Forms form that contains many
I have the following code: public Mainform() { ... // scheduler scheduler.DoWork += new
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
I have a form in a Windows form application that I want to display
I have a form MainForm with several properties/methods that are accessed from another thread.
I have programmed a sub procedure that will be called in the main procedure
So i have one class which starts a new class in a new background
I have an user control in our library that I need to inherit and
We have a ASP.NET MVC 3 application that uses unobtrusive jQuery validation. The page

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.