-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsavecidstatement.php
87 lines (53 loc) · 2.17 KB
/
savecidstatement.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
require_once('database/Database.php');
$db = new Database();
include('session.php');
include('header.php');
include('menubar.php');
include('dbconnect.php');
if(session_status() == PHP_SESSION_NONE)
{
include('session.php');
}
//array created to handle the error msgs
$errors = array();
//Variables to hold the form data
$statement=''; $status=''; $caseid='';
if(empty($_POST['statement'])){
array_push($errors, "The Statefield field cannot be empty, ensure is entered");
}
else{
$statement = $_POST['statement'];
}
if(empty($_POST['status'])){
array_push($errors, "You need select the status field");
}
else{
$status= $_POST['status'];
}
if(empty($_POST['caseid'])){
array_push($errors, "Enter the case id");
}
else{
$caseid= $_POST['caseid'];
}
if($errors){
// $output = array('error' => true, $errors);
foreach($errors as $value){
echo '<span>'. $value.' </span> </br>';
}
}
else{
$sql = "UPDATE investigation SET statement=?,status=? WHERE case_id=?";
$q = $conn->prepare($sql);
$success= $q -> execute(array($statement,$status,$caseid));
if($success)
{
echo "<script>alert('The Statement saved successfully')</script>";
echo "<script>window.open('cidcaseview.php','_self')</script>";
//echo "<script>alert('You have voted already')</script>";
// header( 'Location: cidcaseview.php?message=success' );
}
}
$db->Disconnect();
?>