I'm getting a Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' on line 2 and can't for the life of me figure out why. But I'm a newb so I'm sure the answer is right in front of me. Any ideas?
<?php
class Process {
public function __construct() {
if(isset($_POST['email'])) {
$email = $_POST['email'];
$name = $_POST['yourName'];
$to = $_POST['friendEmail'];
$from = $_POST['yourEmail'];
$message = $_POST['message'];
$htmlMessage .= '<table width="450" border="0" align="center" cellpadding="0" cellspacing="0" style="border:solid 2px #F0B2D1; background-color:#e8ffe8; margin:20px auto;">';
$htmlMessage .= '<tr>';
$htmlMessage .= '<td rowspan="2" valign="top"><img src="http://www.pinktulip.ca/non-wp-code/images/tulip.png" alt="Pink Tulip" width="80" height="145" /></td>';
$htmlMessage .= '<td valign="top" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; padding:10px;"><strong><em>'.strip_tags($name).'</em> has sent you a <a href="http://www.pinktulip.ca/" style="color:#c30062; text-decoration:underline; font-weight:bold;">Pink Tulip</a></strong></td>';
$htmlMessage .= '</tr>';
$htmlMessage .= '<tr>';
$htmlMessage .= '<td style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; padding:10px;"><p>'.strip_tags($message).'</p></td>';
$htmlMessage .= '</tr>';
$htmlMessage .= '<tr>';
$htmlMessage .= '<td colspan="2" style="font-family:Verdana, Arial, Helvetica, sans-serif; font-size:14px; padding:10px; text-align:center;"><strong>Find smart advice for savvy girls at <a href="http://www.pinktulip.ca/" style="color:#c30062; text-decoration:underline; font-weight:bold;">The Pink Tulip</a>.</strong></td></tr></table>';
$email1 = 'There is a problem with your email address';
$characterLimit = 'Too many characters';
$email2 = 'There is a problem with your email address';
$headers = "From: $from\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n".
"Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode($htmlMessage));
session_start();
$_SESSION['name'] = $name;
$_SESSION['from'] = $from;
$_SESSION['message'] = $message;
if(!$this->checkEmail($to)) {
$_SESSION['e_email1'] = $email1;
!$this->checkEmail($from) ? $_SESSION['e_email2'] = $email2 : null;
strlen($name) > 50 ? $_SESSION['e_name'] = $characterLimit : null;
strlen($name) > 250 ? $_SESSION['e_message'] = $characterLimit : null;
$this->redirect('emailError');
} else {
$subject = $_POST['yourName']." has sent you a Pink Tulip!";
$message = $_POST['message'];
$this->procSendEmail($to, $subject, $headers);
$this->redirect();
}
} else {
$this->redirect('error');
}
}
public function procSendEmail($to, $subject, $headers) {
mail($to, $subject, "", $headers);
}
public function redirect($email) {
if($email == 'emailError') { // form has errors
header('Location: /send-a-pink-tulip/?thankYou=0');
} else if($email == 'error') { // form has errors
header('Location: /send-a-pink-tulip/');
} else { // done process.php
header('Location: /send-a-pink-tulip/?thankYou=1');
}
}
public function checkEmail($emailAddress) {
if(strlen($emailAddress = trim($emailAddress)) > 0) {
/* Email validation */
$regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*"."@[a-z0-9-]+(\.[a-z0-9-]{1,})*"."\.([a-z]{2,}){1}$";
if(!eregi($regex, $emailAddress)) {
return false;
}
return true;
}
}
}
/* Initialize process */
$process = new Process;
?>