-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin_update_events_code.php
More file actions
43 lines (37 loc) · 1.17 KB
/
admin_update_events_code.php
File metadata and controls
43 lines (37 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
<?php
//getting values
session_start();
$ev_name = $_POST["event_name"];
$start_date = $_POST["start_date"];
$end_date = $_POST["end_date"];
$conn = new mysqli("localhost", "root", "", "museumsys");
if(mysqli_connect_error()){
die('Connect Error('.mysqli_connect_errno().')'.mysqli_connect_error());
}
else{
//query for updating event details
$UPDATE = "UPDATE museum_events SET date_start = ?, date_end = ? WHERE event_name = ? LIMIT 1";
$SELECT = "SELECT * FROM museum_events WHERE event_name = ?";
//check if event exists or not
$stmt = $conn->prepare($SELECT);
$stmt->bind_param("s", $ev_name);
$stmt->execute();
$stmt->store_result();
$rnum = $stmt->num_rows;
$stmt->close();
if($rnum == 1){
//event exists
$stmt = $conn->prepare($UPDATE);
$stmt->bind_param("sss", $start_date, $end_date, $ev_name);
$stmt->execute();
$_SESSION['msg'] = "<script>window.alert('Details for Event updated successfully')</script>";
header("location: admin_menu.php");
}
else{
$_SESSION['msg'] = "<script>window.alert('Event does not exist')</script>";
header("location: admin_menu.php");
}
$stmt->close();
$conn->close();
}
?>