Does my $to
variable have to equals something in this situation or will my functions fill that in automatically.
<?php
if (isset($_POST["MainCB"])) {
$to = "test@test.com";
}
if (isset($_POST["ITCB"])) {
$to = "test@test.com";
}
if (isset($_POST["CateCB"])) {
$to = "test@test.com";
}
if (isset($_POST['submit'])) {
$full_name = $_POST['full_name'];
$MainCB = $_POST['MainCB'];
$ITCB = $_POST['ITCB'];
$CateCB = $_POST['CateCB'];
$subject = "Form submission";
$message = $full_name . " " . $MainCB . " " . $ITCB . " " . $CateCB;
mail($to, $subject, $message);
include 'mail.php';
}
?>
<html>
<head>
<title>Event Form</title>
<link rel="stylesheet" type="text/css" href="form.css">
</head>
<body>
<h1 id="LOGS">LOGS</h1>
<h1 id="FormTitle">Event Request Form</h1>
<form action="" method="post">
<table id="Table">
<tr id="FullName"><td>Full Name:</td> <td><input type="text" name="full_name"></td></tr>
<tr id="EventT"><td>Event Title:</td> <td><input type="text" name="EventT"></td></tr>
<tr id="Department"><td>Person/Dept in Charge:</td> <td><input type="text" name="InCharge"></td></tr>
<tr id="Venue"><td>Venue:</td> <td><input type="text" name="Venue"></td><tr>
<tr id="Ven"><td>Have you checked venue availability:</td> <td>Yes <input type="checkbox" name ="VenY">No <input type="checkbox" id="VenN" name ="VenN"></td><tr>
<tr id="Adults"><td>No. of Adults:</td> <td><input type="text" name="Adults"></td><tr>
<tr id="Children"><td>No. of Children:</td> <td><input type="text" name="Children"></td><tr>
<tr id="MainCB"><td>Maintenance:</td> <td><input type="checkbox" name ="MainCB"></td><tr>
<tr id="ITCB"><td>IT:</td> <td><input type="checkbox" name="ITCB"></td><tr>
<tr id="CateCB"><td>Catering:</td> <td><input type="checkbox" name="CateCB"></td><tr>
<tr id="CatReq"><td>Catering Requirments:</td></tr>
<tr><td><textarea rows="4" cols="50" name="CatReq"></textarea></td><tr>
<tr id="LogReq"><td>Logistical Requirements/Equipment:</td></tr>
<tr><td><textarea rows="4" cols="50" name="LogReq"></textarea></td><tr>
<tr id="ITReq"><td>IT Requirements:</td></tr>
<tr><td><textarea rows="4" cols="50" name="ITReq"></textarea></td><tr>
<tr id="Trans"><td>Transport Booked:</td> <td>Yes <input type="checkbox" name ="TransY"> No <input type="checkbox" name ="TransN"></td><tr>
<tr id="Email"><td>Email:</td> <td><input type="text" name="Email"></td><tr>
<tr id="EXT"><td>EXT:</td> <td><input type="text" name="Ext"></td><tr>
</table>
<input type="submit" name="submit" value="Submit" id="submitbutton">
</form>
</body>
</html>
<?php
$recipients = array();
if(isset($_POST["MainCB"])) {
$recipients[] = "test@test.com"// one address email;
}
if(isset($_POST["ITCB"])) {
$recipients[] = "test2@test.com"// one other address email;
}
if(isset($_POST["CateCB"])) {
$recipients[] = "test3@test.com"// one more address email;
}
if(isset($_POST['submit']) && !empty($recipients) ){ // You need to have at least one email address to send it
$to = implode(',', $recipients); // All your email address
$full_name = $_POST['full_name'];
$MainCB = $_POST['MainCB'];
$ITCB = $_POST['ITCB'];
$CateCB = $_POST['CateCB'];
$subject = "Form submission";
$message = $full_name . " " . $MainCB . " " . $ITCB . " " . $CateCB;
mail($to,$subject,$message);
include 'mail.php';
}
?>