-
Notifications
You must be signed in to change notification settings - Fork 0
/
task_add.php
56 lines (46 loc) · 1.25 KB
/
task_add.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
<?PHP
require_once("dbconnector.php");
/*
require_once("check_session.php");
if (!checkSession()){
error_log("Session Time out.");
echo "error: Session has timed out. Please login again...";
return false;
}
*/
EditTask();
function EditTask(){
$newproject = false;
$project_id = 0;
/*
if($_SESSION['admin'] == "false"){
error_log("In project_edit: NOT an admin!");
echo "error: not authorised.";
return false;
}
*/
$project_id = $_POST['project_id'];
$task_desc = $_POST['task_desc'];
error_log("task_add.php: project_id = " . $project_id);
error_log("task_add.php: task_desc = " . $task_desc);
$dbConn = opendatabase();
$stmt = $dbConn->stmt_init();
$sql = "INSERT INTO tb_tasks(project_id, task_text) VALUES (?,?);";
error_log("QRY: " . $sql);
if($stmt->prepare($sql)){
// Bind parameters: s - string, b - blob, i - int, etc
$stmt -> bind_param("is", $project_id, $task_desc);
/* Execute it */
$stmt -> execute();
$last_id = $stmt -> insert_id;
error_log("New Record has id: " . $last_id);
/* Close statement */
$stmt -> close();
error_log("Insert/update successful.",0);
echo $last_id;
} else {
error_log("Error!Prepare failed: (" . $dbConn->errno . ") " . $dbConn->error ,0);
}
$dbConn -> close();
}
?>