-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathversionUpdate.php
More file actions
77 lines (57 loc) · 2.21 KB
/
Copy pathversionUpdate.php
File metadata and controls
77 lines (57 loc) · 2.21 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
$errors = array(); // array to hold validation errors
$data = array(); // array to pass back data
// validate the variables ======================================================
// if any of these variables don't exist, add an error to our $errors array
if (empty($_POST['title']))
$errors['title'] = 'Title is required.';
if (empty($_POST['description']))
$errors['description'] = 'Description is required.';
if ( ! empty($errors)) {
// if there are items in our errors array, return those errors
$data['success'] = false;
$data['errors'] = $errors;
} else {
session_start();
require('db.php');
if (isset($_SESSION['username'])){
$username = $_SESSION['username'];
$username = stripslashes($username);
$title = $_POST['title'];
$title = stripslashes($title);
$description = $_POST['description'];
$description = stripslashes($description);
/*
if(isset($_POST['parent'])){
$parent = $_POST['parent'];
$parent = stripslashes($parent);
}else {
$parent = 0;
}
*/
$versionID = $_POST['versionID'];
$projectID = "";
if(isset($_POST['file'])){
$file = $_POST['file'];
}else {
$file = "no file";
}
$query="SELECT * FROM versions WHERE versionID='$versionID'";
$result = mysqli_query($conn, $query) or die(mysqli_error($conn));
$rows = mysqli_num_rows($result);
if($rows>=1){
while($row = mysqli_fetch_array($result)) {
$projectID = $row[0];
}
}else{
}
$query = "UPDATE versions SET title = '$title', description = '$description', file = '$file' WHERE versionID='$versionID'";
$result = mysqli_query($conn, $query) or die(mysqli_error($conn));
}
$data['success'] = true;
$data['message'] = 'Success!';
$data['versionID'] = $versionID;
$data['projectID'] = $projectID;
}
// return all our data to an AJAX call
echo json_encode($data);