-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsave_member.php
35 lines (31 loc) · 1.37 KB
/
save_member.php
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
<?php
require_once 'database.php';
$id = $_POST['id'];
$teams_id = $_POST['teams_id'];
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$position = $_POST['position'];
$department = $_POST['department'];
$about = $_POST['about'];
$image_url = '';
if ($_FILES['image']['name']) {
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["image"]["name"]);
move_uploaded_file($_FILES["image"]["tmp_name"], $target_file);
$image_url = $target_file;
}
if ($id) {
if ($image_url) {
$stmt = $conn->prepare("UPDATE members SET teams_id = ?, firstname = ?, lastname = ?, position = ?, department = ?, about = ?, image_url = ? WHERE id = ?");
$stmt->execute([$teams_id, $firstname, $lastname, $position, $department, $about, $image_url, $id]);
} else {
$stmt = $conn->prepare("UPDATE members SET teams_id = ?, firstname = ?, lastname = ?, position = ?, department = ?, about = ? WHERE id = ?");
$stmt->execute([$teams_id, $firstname, $lastname, $position, $department, $about, $id]);
}
} else {
$stmt = $conn->prepare("INSERT INTO members (teams_id, firstname, lastname, position, department, about, image_url) VALUES (?, ?, ?, ?, ?, ?, ?)");
$stmt->execute([$teams_id, $firstname, $lastname, $position, $department, $about, $image_url]);
}
header("Location: /crud_add_pdf_project/dashboard.php");
exit();
?>