-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_template.php
More file actions
47 lines (38 loc) · 1.17 KB
/
update_template.php
File metadata and controls
47 lines (38 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
session_start();
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] !== true) {
header("Location: login.php");
exit();
}
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "demo";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Bağlantı hatası: " . $conn->connect_error);
}
$response = array();
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$templateID = $_POST['templateID'];
$templateName = $_POST['templateName'];
$subject = $_POST['templateSubject'];
$body = $_POST['templateBody'];
$source = $_POST['templateSource'];
$sql = "UPDATE mails SET m_konu = ?, m_icerik = ?, m_kaynak = ?, m_sablon_ismi = ? WHERE id = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("ssssi", $subject, $body, $source, $templateName, $templateID);
if ($stmt->execute()) {
$response['success'] = true;
} else {
$response['success'] = false;
$response['error'] = $conn->error;
}
$stmt->close();
} else {
$response['success'] = false;
$response['error'] = "Geçersiz istek.";
}
$conn->close();
echo json_encode($response);
?>