Hey liebe Community was ist daran falsch?
Er gibt mir dauernd aus:
Parse error: syntax error, unexpected T_PUBLIC in
/home/www/*****/index.php on line
22
Line 22 ist diese hier:
public function addEntry($email) {
Code:
<?php
define('DB_HOST', 'localhost');
define('DB_NAME', '*****');
define('DB_USERNAME', '****');
define('DB_PASS', '******');
class Newsletter {
private $db;
public function __construct() {
$this->db = new mysqli(DB_HOST, DB_USERNAME, DB_PASS, DB_NAME);
}
public function __destruct() {
$this->db->close();
}
public function addEntry($email) {
}
private function sendConfirmation($to, $from, $key) {
}
public function confirmEmail($key) {
}
}
public function addEntry($email) {
$result = false;
if(!filter_var($email, FILTER_VALIDATE_EMAIL)) return false;
$email_key = md5(uniqid());
$sql = 'INSERT INTO
service4life_email_list (email, email_key, is_active, date)
VALUES(?, ?, "false", NOW())';
$stmt = $this->db->prepare($sql);
$stmt->bind_param('ss', $email, $email_key);
$stmt->execute();
if(!empty($this->db->error)) return false;
$result = $stmt->insert_id;
$stmt->close();
$this->sendConfirmation($email, 'example@example.com', $key);
return (bool)$result;
}
private function sendConfirmation($to, $from, $key) {
$subject = 'Newsletter Bestätigung';
$headers = "From: " . $from . "\r\n";
$headers .= "Reply-To: ". $from . "\r\n";
$headers .= "CC: $from \r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = 'Bitte bestätigen Sie Ihre E-Mail-Adresse für den Newsletter mit ';
$message .= 'folgendem Link: <a href="http://example.com/includes/confirm-email.php?key='.$key.'">Bestätigung</a>';
mail($to, $subject, $message, $headers);
}
public function confirmEmail($key) {
$sql = 'UPDATE service4life_email_list
SET is_active = "true"
WHERE email_key = ?';
$stmt = $this->db->prepare($sql);
$stmt->bind_param('s', $key);
$stmt->execute();
$result = $stmt->affected_rows;
$stmt->close();
return (bool)$result;
}
?>
Ich habe ein Tutorial benutzt aber irgendwas läuft schief

Danke im vorraus