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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:50:58+00:00 2026-05-24T19:50:58+00:00

I have been working on creating a PHP email form recently and cannot manage

  • 0

I have been working on creating a PHP email form recently and cannot manage to send the checkbox values correctly. The form is one I found elsewhere and have been modifying. The HTML is fairly straightforward.

<label for="needs">I am looking for...</label>
<input name="needs[]" id="needs" type="checkbox" value="product list">A Product List<br>
<input name="needs[]" id="needs" type="checkbox" value="educational support">Educational Support<br>
<input name="needs[]" id="needs" type="checkbox" value="catering options">Catering Options<br>
<input name="needs[]" id="needs" type="checkbox" value="party ideas">Party Ideas<br>
<input name="needs[]" id="needs" type="checkbox" value="healthy alternatives">Healthy Alternatives<br>
<input name="needs[]" id="needs" type="checkbox" value="other">Other (please specify)<br>

As of right now, when I send it through the PHP it simply returns either a single selected value or if multiple are selected is says “array”. What I would like is for the message of the mail being sent to me to list the selected values. I have searched elsewhere, but have not found a situation the same as mine yet. Here is the PHP:

<?php
$msg=
'Name:      '.$_POST['name'].'<br />
Category:   '.$_POST['category'].'<br />
Email:      '.$_POST['email'].'<br />
Phone:      '.$_POST['telephone'].'<br />
Looking for:    '.$_POST['needs'].'<br />
IP:     '.$_SERVER['REMOTE_ADDR'].'<br /><br />

Message:<br /><br />

'.nl2br($_POST['message']).'

';
?>

The rest of the code is setup and sending of the message. I realize that there are other ways of doing what I want, but would like to continue using the $msg that is included here.

Any help would be greatly appreciated, thanks.

Modified code:

$msg=
'Name:      '.$_POST['name'].'<br />
Category:   '.$_POST['category'].'<br />
Email:      '.$_POST['email'].'<br />
Phone:      '.$_POST['telephone'].'<br />
Looking for:    '.(is_array($_POST['needs'])?implode("\n", $_POST['needs']):$_POST['needs']).'<br />
IP:     '.$_SERVER['REMOTE_ADDR'].'<br /><br />

Message:<br /><br />

'.nl2br($_POST['message']).'

';
  • 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-24T19:50:58+00:00Added an answer on May 24, 2026 at 7:50 pm

    you should work with $_POST[‘needs’] as with array since it’s really an array. if you want just to get the list of checked checkboxes you can join the array to the string:

    $checked_options = implode("\n", $_POST['needs']);
    

    you can check whether certain option is checked or not:

    if (in_array("educational support", $_POST['needs'])) echo ("educational support is checked");
    

    and so on…

    in your case i would do the following:

    <?php
    $msg=
    'Name:      '.$_POST['name'].'<br />
    Category:   '.$_POST['category'].'<br />
    Email:      '.$_POST['email'].'<br />
    Phone:      '.$_POST['telephone'].'<br />
    Looking for:    '.(is_array($_POST['needs'])?implode("\n", $_POST['needs']):$_POST['needs']).'<br />
    IP:     '.$_SERVER['REMOTE_ADDR'].'<br /><br />
    
    Message:<br /><br />
    '.nl2br($_POST['message']).'
    
    ';
    ?>
    
    '.nl2br($_POST['message']).'
    

    ‘;
    ?>

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

Sidebar

Related Questions

I have been working with relational databases for sometime, but it only recently occurred
I've been working on creating a form that submits content into my database but
In the past years I have been working on different projects that required creating
I have been working with Entity Framework 4 recently, and am slightly confused as
I have a website which I have been working on creating very rapidly, and
I have been working on a project recently where a Player can create a
I have been working on creating an application that sends a string from an
I have been working with an MVC app and creating Repositories that manipulate, validate,
I've been working on creating seo friendly urls for my site and have done
I have been working on a web services related project for about the last

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.