knoxinator Posted December 8, 2015 Share Posted December 8, 2015 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 = "knoxinator2@gmail.com"; $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: myboss@example.com' . "\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 Quote Link to comment https://forums.phpfreaks.com/topic/299674-error-in-sendmailphp/ Share on other sites More sharing options...
mac_gyver Posted December 8, 2015 Share Posted December 8, 2015 the syntax you are using on line 13 is only available in php5.5 and above. Quote Link to comment https://forums.phpfreaks.com/topic/299674-error-in-sendmailphp/#findComment-1527677 Share on other sites More sharing options...
knoxinator Posted December 8, 2015 Author Share Posted December 8, 2015 the syntax you are using on line 13 is only available in php5.5 and above. how do I fix this? Quote Link to comment https://forums.phpfreaks.com/topic/299674-error-in-sendmailphp/#findComment-1527678 Share on other sites More sharing options...
mac_gyver Posted December 8, 2015 Share Posted December 8, 2015 (edited) you have got to be kidding - either upgrade your php version to at least V5.5 or use standard array syntax, that works with all php versions. Edited December 8, 2015 by mac_gyver Quote Link to comment https://forums.phpfreaks.com/topic/299674-error-in-sendmailphp/#findComment-1527679 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.