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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:51:07+00:00 2026-05-29T09:51:07+00:00

When a user selects the radio button that equal sales it send information to

  • 0

When a user selects the radio button that equal sales it send information to the sales department which works fine.

I need when a user selects the support department that have to enter a 5 digit serial number for the device they need support on. The serial number has to be between 3 to 5 numbers only. If the serial is not 3 to 5 numbers example:

in this box if the numbers are 123 submit, if 12324 submit, if x3423 die, if 12 die, if 123456 die. also I need for to only accept numbers.

Can I do this

if($selected == 'sales') {
    $body = "From: $name_field\n E-Mail: $email_field\n Address: $address\n City: $city\n State: $state\n PostalCode: $zip\n Department $selected\n How did you about us: $hear\n Country: $country\n  Comments: $comment";
    mail($to, $subject, $body);
    header("Location: http://url/");
}     
else if($selected == 'support') {
    if(preg_match("/^\d{3}$|^\d{5}$/", $_POST['serial']) === 0) {
        $body = "From: $name_field\n E-Mail: $email_field\n Address: $address\n City: $city\n State: $state\n PostalCode: $zip\n Department $selected\n How did you about us: $hear\n Country: $country\n Serial Number: $serial\n  Comments: $comment";
        mail($toa, $subject2, $body);
        header("Location: http://url/");
    }
    else {
        die('<script type="text/javascript"> alert("Serial Number is invalid");</script>');
    }
}
}
  • 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-29T09:51:08+00:00Added an answer on May 29, 2026 at 9:51 am

    You are currently having it send the email if the regex fails to match. Your regex is wrong too. There’s a few minor things too.

    Try this:

    switch($selected) {
        case "sales":
            $body = "From........................";
            mail($to,$subject,$body);
            header("Location: .....");
            exit;
        case "support":
            if( preg_match("(^[0-9]{3,5}$)",$_POST['serial'])) {
                $body = "From.......................";
                mail($toa,$subject2,$body);
                header("Location: ......");
                exit;
            }
            else {
                die("Serial Number is invalid!");
            }
        default:
            die("Invalid department selection.");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Situation:- I have created a RadioButton group. When a User selects a radio button
I have 2 radio buttons, what I want is if a user selects the
I have some options for pricing using radio buttons. When a user selects the
I have a form in which the user selects a few items to display
I have a program in which a user selects a row in a Datagrid
I haver a simple radio button list on my page that I render with
I have 2 radio button (i.e., <input type=radio>) with values yes,no Now, I need
I have the following code that controls radio button options shown one level at
When the user is hovering on a radio button/its label i want to display
The first Activity has two Radio Buttons and the user selects either one, and

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.