hello I can't seem to figure out my error
<?php
if(empty($_POST) === false) {
session_start();
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
$errors = [];
if(isset($_POST['name'], $_POST['phone'], $_POST['date'], $_POST['type'], $_POST['message'])) {
$fields = [
'name' => $_POST['name'],
'phone' => $_POST['phone'],
'date' => $_POST['date'],
'type' => $_POST['type'],
'message' => $_POST['message']
];
foreach ($fields as $field => $data) {
if(empty($data)) {
$errors[] = "The " . $field . " is required";
}
}
if(empty($errors) === true) {
$name = test_input($_POST['name']);
$phone = test_input($_POST['phone']);
$date = test_input($_POST['date']);
$type = test_input($_POST['type']);
$message = test_input($_POST['message']);
$to = "
[email protected]";
$subject = "Hello I am " . $name;
echo $body = "
<html>
<head>
<title>Contact Form</title>
<style>
body {
background-color: #EEEEEE;
}
.main {
width: 960px;
margin: 0 auto;
background-color: white;
padding: 100px;
}
.main h3 {
color: green;
margin-bottom: 30px;
}
table, tr, th, td {
border: 1px solid lightGray;
border-collapse: collapse;
font-size: 20px;
}
th, td {
padding: 5px;
text-align: justify;
line-height: 30px;
}
.footer {
line-height: 5px;
margin-top: 50px;
color: green;
}
</style>
</head>
<body>
<div class='main'>
<h3>Hello,<br>I am $name, my information is bellow_</h3>
<table>
<tr>
<th>Name</th>
<td>$name</td>
</tr>
<tr>
<th>Phone</th>
<td>$phone</td>
</tr>
<tr>
<th>Date</th>
<td>$date</td>
</tr>
<tr>
<th>Moving Type</th>
<td>$type</td>
</tr>
<tr>
<th>Message</th>
<td>$message</td>
</tr>
</table>
<div class='footer'>
<h3>Thank you.</h3>
<h3>$name</h3>
</div>
</div>
</body>
</html>
";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: <' . $name . '>' . "\r\n";
//$headers .= 'Cc:
[email protected]' . "\r\n";
mail($to,$subject,$body,$headers);
$_SESSION['success'] = "Success";
header('location: index.php');
exit();
} elseif(empty($errors) === false) {
echo "Wrong";
$_SESSION['fields'] = $fields;
$_SESSION['errors'] = $errors;
header('location: index.php');
exit();
}
}
} else {
header('location: index.php');
exit();
}
the error I am getting is
Parse error: syntax error, unexpected '[' in G:\PleskVhosts\footydoubles.info\T20Empire.com\sendmail.php on line 13