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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:24:08+00:00 2026-06-01T01:24:08+00:00

I apologize if it is stupid question. I wanted to check whether one or

  • 0

I apologize if it is stupid question. I wanted to check whether one or more checkboxes are not empty, then can process the form and print interest text for email.

HTML/PHP

<p><label for="commentsText">I am interested in:</label><br/>
<input type="checkbox" name="interest[]" id="interest" value="1" class="required requiredField email" /> 
    Exhibiting. Please send me more information<br/>
<input type="checkbox" name="interest[]" id="interest" value="2" class="required requiredField email" /> 
    Visiting. Please add me to your mailing list<br/>
<input type="checkbox" name="interest[]" id="interest" value="3" class="required requiredField email" /> 
    Speaking. Please send me more information<br/>
<input type="checkbox" name="interest[]" id="interest" value="4" class="required requiredField email" /> 
    Attending. Please send me more information<br/>

<?php if($interestError != '') { ?>
<span class="error"><?php echo $interestError; ?></span>
<?php } ?>
</p>

PHP

$interest='';    
if(empty($_POST[$interest]))
{ 
    $interestError ='Please select the interests';
    $hasError = true;
}
else{
    $numberofInterest = count($interest);
    for ($i=0; $i < $numberofInterest; $i++)
    {
        $numofInterest = $interest[i];
        echo $numofInterest . " ";
    }
}

EDIT #2

Thank you everybody for the help. I used print_r and saw all four are printed. The problem is now: if no error, send mail. It doesn’t show all when I checked all checkboxes. Only displays ‘4’. Is there a way to display all including texts?

if(!isset($hasError)) {

        $interest = $numofInterest ;

    $subject = 'I Have A Question to Ask from '.$name;
            $thanksubject = 'Thank you for the Form Submission';
            $body = "Name: $name \n\nEmail: $email \n\nInterest: $interest\n\nComments: $comments";

*EDIT #3*

OK I have solved that last one above. managed to send email with everything.

  • 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-01T01:24:09+00:00Added an answer on June 1, 2026 at 1:24 am

    When the form is submitted the PHP script will receive an array of the checked boxes in the $_GET or $_POST variable respectively (or you could just use $_REQUEST)

    I.e. when the first and third checkbox is checked, a print_r($_POST['interest']); will output:

    Array
    (
        [0] => 1
        [1] => 3
    )
    

    I think your main mistake, is the way you index the $_POST-variable – you use the variable $interest where you should have used the string 'interest', like above.

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

Sidebar

Related Questions

This may be a stupid question and if it is then I apologize. I
I would like to apologize at first instant for asking some stupid question(well not
I apologize for asking such a generalized question, but it's something that can prove
I apologize in advance if this question seems remedial. Which would be considered more
First of all, I apologize if this is a stupid question, I'm a dead
My apologies if this is a stupid question, however I can't find any information
I want to apologize for this stupid question; I'm new to RequireJS. This is
I apologize in advance for asking such a stupid question, but how do I
I am not even sure whether the title of my question is correct, but
Apologies if this is a stupid question, I'm relatively new to Matlab. I've got

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.