Alright so what I'm trying to do is send the form data to the value of whatever checkbox is checked in checkbox_1.

<title>Untitled Document</title>
<h1>Student Request Form</h1>


if(isset($_POST['checkbox_1'])) {
$checkbox_1 = implode(",", $_POST['checkbox_1']);
$to=implode(",", $_POST['checkbox_1']);

$subject = "My subject";
$txt = "Hello world!";
} else {
$checkbox_1 = "";

if(isset($_POST['checkbox_2'])) {
$checkbox_2 = implode(",", $_POST['checkbox_2']);   
} else {
$checkbox_2 = "";


$con = mysqli_connect("localhost","root","admin","form2");
if (mysqli_connect_errno())
  echo "Failed to connect to MySQL: " . mysqli_connect_error();

/*Get Values from form*/

 if(isset($_POST['todays_date'])){ $todays_date = $_POST['todays_date']; }
 if(isset($_POST['student_fname'])){ $student_fname = $_POST['student_fname']; }
 if(isset($_POST['student_lname'])){ $student_lname = $_POST['student_lname']; }
 if(isset($_POST['student_id'])){ $student_id = $_POST['student_id']; }
 if(isset($_POST['phone_number'])){ $phone_number = $_POST['phone_number'];}
 if(isset($_POST['student_email'])){ $student_email = $_POST['student_email']; }
 if(isset($_POST['course_num1'])){ $course_num1 = $_POST['course_num1']; }
 if(isset($_POST['course_num2'])){ $course_num2 = $_POST['course_num2']; }
 if(isset($_POST['course_num3'])){ $course_num3 = $_POST['course_num3']; }
 if(isset($_POST['section_num1'])){ $section_num1 = $_POST['section_num1']; }
 if(isset($_POST['section_num2'])){ $section_num2 = $_POST['section_num2']; }
 if(isset($_POST['section_num3'])){ $section_num3 = $_POST['section_num3']; }
 if(isset($_POST['request_box'])){ $request_box = $_POST['request_box']; }
 if(isset($_POST['signature'])){ $signature = $_POST['signature']; }
 if(isset($_POST['sig_date'])){ $sig_date = $_POST['sig_date']; }
 if(isset($_POST['request_box'])){ $request_box = $_POST['request_box']; }


mysqli_query($con,"INSERT INTO student_form(todays_date, student_fname, student_lname, student_id, phone_number, student_email, course_num1, course_num2, course_num3, section_num1, section_num2, section_num3, checkbox_1, checkbox_2, request_box, signature, sig_date)  VALUES( '$todays_date','$student_fname','$student_lname', '$student_id','$phone_number','$student_email','$course_num1','$course_num2','$course_num3','$section_num1','$section_num2','$section_num3','$checkbox_1','$checkbox_2','$request_box','signature','sig_date')")


<form action="index.php" method="post">
<b>Today's Date</b><input name="todays_date" type="text" id="todays_date"><br />
<b>Your Name:</b> 
First:<input name="student_fname" type="text" id="student_fname">
Last:<input name="student_lname" type="text" id="student_lname"><br />
<b>Student ID:</b><input name="student_id" type="text" id="student_id"><br />
<b>Phone:</b><input name="phone_number" type="text" id="phone_number"><br />
<b>ITT Email:</b><input name="student_email" type="text" id="student_email">@email.itt-tech<br />
<b>*Responses will only be sent to ITT mailboxes</b>
<br />
<br />

<table border="1" style="width:300px">

<th colspan=2 >Course(s) for tutoring Schedule</th>
<th>Course Number</th>
<th>Section Number</th>

<td><input name="course_num1" type="text" id="course_num1"></td>
<td><input name="section_num1" type="text" id="section_num1"></td>
<td><input name="course_num2" type="text" id="course_num2"></td>
<td><input name="section_num2" type="text" id="section_num2"></td>
<td><input name="course_num3" type="text" id="course_num3"></td>
<td><input name="section_num3" type="text" id="section_num3"></td>

<br />

<h3>I request service from:</h3>

<input name="checkbox_1[]" type="checkbox" value="mpike898@gmail.com" />Dean, Edward Feltis<br />
<input name="checkbox_1[]" type="checkbox" value="RDel_Rosario@itt-tech.edu"/>Associate Dean, Rick Del Rosario<br />
<input name="checkbox_1[]" type="checkbox" value="BSchwartz@itt-tech.edu"/>Associate Dean of General Studies, Dr. Barry Schwartz<br />
<input name="checkbox_1[]" type="checkbox" value="MHawthorne@itt-tech.edu"/>Chair of Business, Michael Hawthorne<br />
<input name="checkbox_1[]" type="checkbox" value="JSinger@itt-tech.edu"/>Chair of Criminal Justice, Justin Singer<br />
<input name="checkbox_1[]" type="checkbox" value="tstangl@itt-tech.edu" />Chair of Electronics Tech, Thomas Stangl<br />
<input name="checkbox_1[]" type="checkbox" value="sclawson@itt-tech.edu" />Chair of information Tech, Shane Clawson<br />
<br />
<h3>I request the following service(Check all that apply):</h3>

<input name="checkbox_2[]" type="checkbox" value="Class Change" />Class Change<br />
<input name="checkbox_2[]" type="checkbox" value="Program Drop"/>Program Drop<br />
<input name="checkbox_2[]" type="checkbox" value="Program Change"/>Program Change<br />
<input name="checkbox_2[]" type="checkbox" value="Class Drop"/>Class Drop<br />
<input name="checkbox_2[]" type="checkbox" value="Campus Transfer"/>Campus Transfer<br />
<input name="checkbox_2[]" type="checkbox" value="Other" />Other<br />

<h3>Detailed reason for this request:</h3>
<textarea name="request_box" id="request_box"rows="8" cols="52">
<br />
<br />

Signature:<input name="signature" type="text" id="signature">
Date:<input name="sig_date" type="text" id="sig_date"><br />

<br />
<br />

<input name="submit" type="submit" value="submit" />


Any suggestions or help would be much appreciated.

3 Years
Discussion Span
Last Post by iamthwee

One way of going about this would be to loop your checkbox array and send an email for each item in the array. This is not fully working code, but it will give you the idea of how to go about sending emails to each email in the checkbox array.

$subject = 'Email Subject Line';
$body = 'Your Email Message';

$checkbox_array = array();

foreach($checkbox_array as $email){

    mail($email, $subject, $body, "From: youremail@domain.dev");


Isolate the problemo...

  1. Does a simple email work?
  2. Does sending text to an email work?
  3. Does sending the body of a form in an email work?
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.