123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
-
- require_once 'config.php';
- require_once 'dbh.inc.php';
- require_once 'checkLogin.php';
-
-
-
- if(isset($_POST['updateExperience'])) {
-
-
- $id = mysqli_real_escape_string($connection, trim($_POST['id']));
-
-
-
- if($id === "") {
- http_response_code(400);
- echo json_encode(array("error" => "Please specify experience ID."));
- exit();
- } else if(mysqli_query($connection, "SELECT * FROM experience WHERE id = '$id';")->num_rows !== 1) {
- http_response_code(400);
- echo json_encode(array("error" => "Given experience ID ($id) not in database."));
- exit();
- }
-
-
-
- if(isset($_POST['newTitle'])) {
-
- $newTitle = mysqli_real_escape_string($connection, trim($_POST['newTitle']));
-
-
-
- if($newTitle === "") {
- http_response_code(400);
- echo json_encode(array("error" => "Please specify title."));
- exit();
- } else if(mb_strlen($newTitle) > 60) {
- http_response_code(400);
- echo json_encode(array("error" => "Title too long (max. is 60 characters)."));
- exit();
- }
-
- $query = "UPDATE `experience` SET `title` = '$newTitle' WHERE `id` = '$id';";
- $result = mysqli_query($connection, $query) or die("Error: ".mysqli_error($connection));
-
- }
-
-
- if(isset($_POST['newDescription'])) {
-
- $newDescription = mysqli_real_escape_string($connection, trim($_POST['newDescription']));
-
-
-
- if($newDescription === "") {
- http_response_code(400);
- echo json_encode(array("error" => "Please specify description."));
- exit();
- } else if(mb_strlen($newDescription) > 100) {
- http_response_code(400);
- echo json_encode(array("error" => "Description too long (max. is 100 characters)."));
- exit();
- }
-
- $query = "UPDATE `experience` SET `description` = '$newDescription' WHERE `id` = '$id';";
- $result = mysqli_query($connection, $query) or die("Error: ".mysqli_error($connection));
-
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
-
|