Jump to content

Recommended Posts

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

 

 

Link to comment
https://forums.phpfreaks.com/topic/299674-error-in-sendmailphp/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.