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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:46:24+00:00 2026-06-18T15:46:24+00:00

Hello Fellow Stackers, New to PHP and I am putting together a multipage form

  • 0

Hello Fellow Stackers,

New to PHP and I am putting together a multipage form from pre-built code.

Basically the user selects as many checkboxes as they want… then the form submits to this secondary page. This secondary page echo’s the checkboxes they chose at the top of the page via $check.. then they can enter their contact information and all of the information gets submitted via form, along with the $check information.

Everything is working perfectly except $check isn’t being entered into the form message, but it works up at the top of the page, displaying which options the user inputted.

Any help is appreciated!

<?php
$emailOut = '';
if(!empty($_POST['choices'])) {
foreach($_POST['choices'] as $check) {
            echo $check; //echoes the value set in the HTML form for each checked checkbox.
                     //so, if I were to check 1, 3, and 5 it would echo value 1, value 3, value 5.
                     //in your case, it would echo whatever $row['Report ID'] is equivalent to.
            $emailOut .= $check."\n"; //any output you want
}
}
$errors = '';
$myemail = 'test@myemailHERE.com';//<-----Put Your email address here.
if(empty($_POST['name'])  || 
   empty($_POST['email']) || 
   empty($_POST['message']))
{
$errors .= "\n Error: all fields are required";
}

$name = $_POST['name']; 
$email_address = $_POST['email']; 
$message = $_POST['message']; 

if (!preg_match(
"/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", 
$email_address))
{
    $errors .= "\n Error: Invalid email address";
}

if( empty($errors))
{
$to = $myemail; 
$email_subject = "Contact form submission: $name";
$email_body = "You have received a new message. $check ".
" Here are the details:\n Name: $name \n Email: $email_address \n Message \n $message \n $emailOut"; 

$headers = "From: $myemail\n"; 
$headers .= "Reply-To: $email_address";

mail($to,$email_subject,$email_body,$headers);
//redirect to the 'thank you' page
header('Location: contact-form-thank-you.html');
} 
?>
  • 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-18T15:46:26+00:00Added an answer on June 18, 2026 at 3:46 pm

    The thing in this situation is that when you get down to the email, $check is the last option displayed. You need to use the foreach statment to build the array or email output such as

    $emailOut = "";
    foreach($_POST['choices'] as $check) {
            $emailOut .= $check."\n"; //any output you want
    }
    

    Then use your email variable in the same way

    $email_body = "You have received a new message. Here are the details:\n Name: $name \n Email: $email_address \n Message \n     $message \n $emailOut";
    

    UPDATE

    From further investigation and more code submitted, it appears that you are working with a multi-form submssion issue. The issue is you have form 1 (checkboxes) that submits to form 2 (email).

    Since when doing the checks after the checkbox submission, no name, email, etc was given so $errors were given and no email sent. When filling out the email form, the checkboxes were not sent again so $check or even $_POST['choices'] had values.

    You can either put the two forms into one, or you can look into a way to save the values by passing them and filling a ‘hidden’ field (<input type='hidden' value='...'>) or use a session with PHP.

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

Sidebar

Related Questions

Hello fellow stackoverflow members! I'm very new to the C# language transfer from Java,
I am currently using this code(from a fellow user here) to find every cell
Hello there fellow Stackers! I wonder if anybody could tell me what the following
Hello fellow programmers, as you might know from my previous questions I'm an absolute
Hello Again my fellow programmers out there, I'm designing and programming from scratch a
hello fellow programmers, I followed a tutorial at http://www.androidsnippets.com/encrypt-decrypt-between-android-and-php to send a String encrypted
Hello fellow stakoverflowers, I'm having a problem with PHP/Apache. I have an application that
Fellow JQuery hackers, hello :-) Suppose you have the following code: $('.links').click(function(){ //Do something
Hello fellow developers! I am trying to get the build error codes from a
CODE HERE: http://jsfiddle.net/B7Y43/ Hello fello programmers, I have the following situation: My PHP-script generates

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.