forked from LamCiuLoeng/BookShare
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsave_upload.php
More file actions
35 lines (27 loc) · 800 Bytes
/
save_upload.php
File metadata and controls
35 lines (27 loc) · 800 Bytes
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('util.php');
require_once 'db_helper.php';
if ($_FILES['file_01']['tmp_name']) {
$f = handleUpload('file_01');
if(!$f){
message('Error occur when uploading the image!');
return redirect('upload.php');
}
}else{
$f = '';
}
$db = getDBInstance();
$name = $_REQUEST['name'];
$desc = $_REQUEST['description'];
$short_desc = $_REQUEST['short_description'];
$point = 1;
$create_by = $_SESSION['user']->id;
addBook($db, $name, $desc, $short_desc, $f, $point, $create_by);
// add the point once the user upload the book
updateUserPoints($db, $_SESSION['user']->id, $point);
$new_points = $_SESSION['user']->points + $point;
$_SESSION['use']->points = $new_points;
$db->debug();
message('Upload successfully!');
redirect('index.php');
?>