Hi all,
I have a form and want the email to be sent based on the person selected...so, if karen is selected, send the email to x address...here is the code
<?php
//process the email
if (array_key_exists('send', $_POST)) {
if ($librarian == kim) {
$to = 'circulation@stony.edu;
$subject = 'Instruction Request';
$additionalHeaders = "From: Instruction Request<reference@stony.edu>\r\n";
}
elseif ($librarian == 'john') {
$to = 'john@stony.edu';
$subject = 'Instruction Request';
$additionalHeaders = "From: Instruction Request<reference@stony.edu>\r\n";
}
elseif ($librarian == 'alice') {
$to = 'alice@stony.edu';
$subject = 'Instruction Request';
$additionalHeaders = "From: Instruction Request<reference@stony.edu>\r\n";
}
elseif ($librarian == 'robert') {
$to = 'robert@stony.edu';
$subject = 'Instruction Request';
$additionalHeaders = "From: Instruction Request<reference@stony.edu>\r\n";
}
else {
$to = 'alexa@philau.edu';
$subject = 'Instruction Request';
$additionalHeaders = "From: Instruction Request<reference@stony.edu>\r\n";
}
//list expected fields
$expected = array('name', 'email', 'course', 'classlocation', 'daysmet', 'starttime', 'endtime', 'studentnumber', 'students', 'date1', 'classtime1', 'date2', 'classtime2', 'date3', 'classtime3', 'librarian', 'location', 'assignmentdate', 'assignment', 'outcomes', 'topic');
//required
$required = array('name', 'email', 'course', 'classlocation', 'daysmet', 'starttime', 'endtime', 'studentnumber', 'date1', 'classtime1', 'date2', 'classtime2', 'librarian', 'location', 'assignmentdate', 'outcomes');
//build the message
$message = "Name: $name\n\n";
$message .= "Email: $email\n\n";
$message .= "Course: $course\n\n";
$message .= "Course Location: $classlocation\n\n";
$message .= "Days Met: $daysmet\n\n";
$message .= "Start time: $starttime\n\n";
$message .= "End time: $endtime\n\n";
$message .= "Student Number: $studentnumber\n\n";
$message .= "Students: $students\n\n";
$message .= "Date 1: $date1\n\n";
$message .= "Classtime: $classtime1\n\n";
$message .= "Date 2: $date2\n\n";
$message .= "Classtime: $classtime2\n\n";
$message .= "Date 3: $date3\n\n";
$message .= "Classtime: $classtime3\n\n";
$message .= "Librarian: $librarian\n\n";
$message .= "Location: $location\n\n";
$message .= "Assignment Date: $assignmentdate\n\n";
$message .= "Assignment Description: $assignment\n\n";
$message .= "Outcomes: $outcomes";
$message .= "Topic: $topic";
...
<span class="heading">Preferred Librarian:</span><span class="boldInline">*</span><?php if (isset($missing) && in_array('librarian', $missing)) { ?>
<span class="warning">Please select the preferred librarian who you would like to teach the seesion</span><?php } ?><br/>
<strong>
<select name="librarian" size="1" required="required">
<option value="not selected"
<?php
if (!$_POST || $_POST['librarian'] == 'not selected') { ?> selected="selected" <?php } ?>>Not selected</option>
<option value="karen" <?php if (isset($missing) && $_POST['librarian'] == 'karen') { ?> selected="selected" <?php } ?>> Karen Albert (Science and Health)</option>
<option value="stan" <?php if (isset($missing) && $_POST['librarian'] == 'stan') { ?> selected="selected" <?php } ?>>Stan Gorski (Fashion, Psychology and Health Sciences)</option>
<option value="barbara" <?php if (isset($missing) && $_POST['librarian'] == 'barbara') { ?> selected="selected" <?php } ?>>Barbara Lowry (Engineering and Textiles; Business)</option>
<option value="brynne" <?php if (isset($missing) && $_POST['librarian'] == 'brynne') { ?> selected="selected" <?php } ?> >Brynne Norton (Architecture and Design)</option>
<option value="jordana" <?php if (isset($missing) && $_POST['librarian'] == 'jordana') { ?> selected="selected" <?php } ?> >Jordana Shane (Liberal Arts)
</option>
I'm printing the variable $librarian so I know the variable is being captured (i.e., kim is being output as the variable value if kim is selected), however, the email is still sent to me, which indicates, in the if clause, the if statements are not recognizing the librarian variable is kim, for instance.
Thanks for your help; I'll keep looking for an answer, too.
Alexa