-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsud2.php
More file actions
56 lines (47 loc) · 1.55 KB
/
consud2.php
File metadata and controls
56 lines (47 loc) · 1.55 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
48
49
50
51
52
53
54
55
56
<?php
session_start();
$db = mysqli_connect('localhost', 'root', '', 'ims');
// initialize variables
$intdate = "";
$type = "";
$brand = "";
$size = "";
$noitem = "";
$idno = "";
$cons_id = 0;
$update = false;
if (isset($_POST['save'])) {
$cons_id = $_POST['cons_id'];
$idno = $_POST['idno'];
$intdate = $_POST['intdate'];
$type = $_POST['type'];
$brand = $_POST['brand'];
$size = $_POST['size'];
$noitem = $_POST['noitem'];
mysqli_query($db, "INSERT INTO cons (idno,intdate,type,brand,size,noitem) VALUES ('$idno', '$intdate', '$type', '$brand', '$size', '$noitem')");
$_SESSION['message'] = "A consumable item is saved!";
header('location: consud3.php');
}
if (isset($_POST['update'])) {
$cons_id = $_POST['cons_id'];
$idno = $_POST['idno'];
$intdate = $_POST['intdate'];
$type = $_POST['type'];
$brand = $_POST['brand'];
$size = $_POST['size'];
$noitem = $_POST['noitem'];
mysqli_query($db, "UPDATE cons SET idno='$idno', intdate='$intdate', type='$type', brand='$brand', size='$size', noitem='$noitem' WHERE cons_id= '$cons_id' ");
$_SESSION['message'] = "A consumable item is updated!";
header('location: consud.php');
// header('Location: ' . $_SERVER['HTTP_REFERER']);
// header("location:javascript://history.go(-1)");
}
if (isset($_GET['del'])) {
$cons_id = trim($_GET['del']);
// $lab_id = strip_tags($idno);
// $idno = htmlspecialchars($idno);
mysqli_query($db, "DELETE FROM cons WHERE cons_id='$cons_id'");
$_SESSION['message'] = "A consumable item is deleted!";
header('location: consud3.php');
}
?>