From c1484e4710edd5a13715abfa6e32cc5a0b297362 Mon Sep 17 00:00:00 2001 From: neerholt Date: Fri, 19 Mar 2021 09:18:19 +0100 Subject: [PATCH 1/3] Added some headers --- Backend/Controllers/FileHandler/GetGameData.php | 3 ++- Backend/Controllers/GameJam/GetGameJam.php | 7 ++++--- Backend/Controllers/Group/GetGroup.php | 2 ++ Backend/Controllers/Polls/GetWinner.php | 3 +++ Backend/Controllers/keyWord/GetKeyWinner.php | 6 ++++-- Backend/Main.php | 15 +++++++++++++++ Frontend/Javascript/qweData.js | 12 ++++++++---- 7 files changed, 38 insertions(+), 10 deletions(-) diff --git a/Backend/Controllers/FileHandler/GetGameData.php b/Backend/Controllers/FileHandler/GetGameData.php index 90c00bd..01445c6 100644 --- a/Backend/Controllers/FileHandler/GetGameData.php +++ b/Backend/Controllers/FileHandler/GetGameData.php @@ -14,6 +14,7 @@ if(isset($_GET['gameDataId'])){ $openGameDataStream = GameData::all(); } - +header("Access-Control-Allow-Methods: GET"); +header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept"); header('Content-Type: application/json;charset=UTF-8'); echo $openGameDataStream->toJson(JSON_PRETTY_PRINT); \ No newline at end of file diff --git a/Backend/Controllers/GameJam/GetGameJam.php b/Backend/Controllers/GameJam/GetGameJam.php index 5e1e345..1dd4d1b 100644 --- a/Backend/Controllers/GameJam/GetGameJam.php +++ b/Backend/Controllers/GameJam/GetGameJam.php @@ -9,8 +9,9 @@ if(isset($_GET['gameJamId'])){ $dbValue = GameJam::all(); } -header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Methods: GET"); -header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept"); +header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept"); header('Content-Type: application/json;charset=UTF-8'); -echo $dbValue->toJson(JSON_PRETTY_PRINT); \ No newline at end of file +echo $dbValue->toJson(JSON_PRETTY_PRINT); + +//var_dump(headers_list()); \ No newline at end of file diff --git a/Backend/Controllers/Group/GetGroup.php b/Backend/Controllers/Group/GetGroup.php index 9a961a1..dad8464 100644 --- a/Backend/Controllers/Group/GetGroup.php +++ b/Backend/Controllers/Group/GetGroup.php @@ -12,5 +12,7 @@ else{ $groups = Group::all(); } +header("Access-Control-Allow-Methods: GET"); +header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept"); header('Content-Type: application/json;charset=UTF-8'); echo $groups->toJson(JSON_PRETTY_PRINT); \ No newline at end of file diff --git a/Backend/Controllers/Polls/GetWinner.php b/Backend/Controllers/Polls/GetWinner.php index bb535f0..a81710d 100644 --- a/Backend/Controllers/Polls/GetWinner.php +++ b/Backend/Controllers/Polls/GetWinner.php @@ -21,6 +21,9 @@ if(isAdmin() && isset($_GET['gameJamId'])){ $winningGroups->push($group); } } + + header("Access-Control-Allow-Methods: GET"); + header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept"); header('Content-Type: application/json;charset=UTF-8'); echo $winningGroups->toJson(JSON_PRETTY_PRINT); diff --git a/Backend/Controllers/keyWord/GetKeyWinner.php b/Backend/Controllers/keyWord/GetKeyWinner.php index 3628bee..1000131 100644 --- a/Backend/Controllers/keyWord/GetKeyWinner.php +++ b/Backend/Controllers/keyWord/GetKeyWinner.php @@ -8,14 +8,16 @@ use \Backend\Models\GameJam; use \Illuminate\Support\Collection; if (!isAdmin()){ - if(isset($_POST['genKeyWord'])){ - $gameJamId = $_POST['gameJamId']; + if(isset($_GET['genKeyWord'])){ + $gameJamId = $_GET['gameJamId']; $game_jam = GameJam::find($gameJamId); $all_group_in_game_jam_id = Group::where("game_jam_id", $game_jam->id)->pluck("id")->toArray(); $find_all_keywords = KeyWord::whereIn("group_id", $all_group_in_game_jam_id)->inRandomOrder()->get(); $game_jam->key_word = $find_all_keywords->first()->key_word; $game_jam->save(); + header("Access-Control-Allow-Methods: GET"); + header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept"); header('Content-Type: application/json;charset=UTF-8'); echo $find_all_keywords->pluck("key_word")->toJson(JSON_PRETTY_PRINT); } diff --git a/Backend/Main.php b/Backend/Main.php index 825a77a..9e8ec94 100644 --- a/Backend/Main.php +++ b/Backend/Main.php @@ -33,6 +33,21 @@ $gameJam = GameJam::firstOrCreate([ + $value) { + echo "$name: $value
"; +} + +echo "
"; + +var_dump(headers_list()); + +?> + diff --git a/Frontend/Javascript/qweData.js b/Frontend/Javascript/qweData.js index c3b2c9a..2770f4c 100644 --- a/Frontend/Javascript/qweData.js +++ b/Frontend/Javascript/qweData.js @@ -6,10 +6,14 @@ $(window).on("load", function(){ function dataFetch(){ $.ajax({ type: "GET", - url: "/Game-Jaming/Backend/Controllers/FileHandler/GetGameData.php?gameJamId=1", + url: "/Game-Jaming/Backend/controllers/GameJam/GetGameJam.php", success: function(result){ - console.log(result); - console.log(result[0].game_link) + console.log(result[0].name); } }); -} \ No newline at end of file +} + + + +//console.log(result.name); ?gameJamId=1 +//console.log(result[0].name); uden ?gameJamId=1 \ No newline at end of file From 409556ca2e63f756c1d9204adc2970bb88e8d76a Mon Sep 17 00:00:00 2001 From: Thomas FJ Date: Fri, 19 Mar 2021 10:48:42 +0100 Subject: [PATCH 2/3] en fil der tillader en admin at oprette en my admin --- Backend/Controllers/Admin/AdminSignup.php | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Backend/Controllers/Admin/AdminSignup.php diff --git a/Backend/Controllers/Admin/AdminSignup.php b/Backend/Controllers/Admin/AdminSignup.php new file mode 100644 index 0000000..8c7910e --- /dev/null +++ b/Backend/Controllers/Admin/AdminSignup.php @@ -0,0 +1,26 @@ +user_name = $_POST["newUsername"]; + $admin->password = $_POST["newPassword"]; + if ($admin->save()){ + header("location: ../../../Frontend/Html/AdminPage.html?success=adminUserWasCreated"); + exit(); + }else{ + header("location: ../../../Frontend/Html/AdminPage.html?error=errorWhileSaving"); + exit(); + } + }else{ + header("location: ../../../Frontend/Html/AdminPage.html?error=input:newAdmin.notSet"); + exit(); + } +}else{ + header("location: ../../../Frontend/index.html?error=isNotAdministrator"); + exit(); +} \ No newline at end of file From 171e0a3765bc512a57750dd895111451715aead1 Mon Sep 17 00:00:00 2001 From: neerholt Date: Fri, 19 Mar 2021 13:25:27 +0100 Subject: [PATCH 3/3] Added http response code --- Backend/Controllers/Admin/AdminLogin.php | 14 +++++------ Backend/Controllers/Admin/AdminSignup.php | 12 ++++------ .../Controllers/FileHandler/FileHandler.php | 10 ++++---- .../Controllers/FileHandler/gameHandler.php | 1 - .../Controllers/FileHandler/updateFiles.php | 15 ++++++------ Backend/Controllers/FileHandler/upload.php | 23 ++++++++++--------- Backend/Controllers/GameJam/NewGameJam.php | 12 ++++------ Backend/Controllers/GameJam/UpdateGameJam.php | 12 ++++------ Backend/Controllers/Group/Login.php | 17 ++++++-------- Backend/Controllers/Group/ResetPassword.php | 14 +++++------ Backend/Controllers/Group/SigningUp.php | 13 +++++------ Backend/Controllers/Group/UpdateGruop.php | 14 +++++------ Backend/Controllers/Group/UpdatePassword.php | 14 +++++------ Backend/Controllers/Polls/1vote.php | 14 +++++------ Backend/Controllers/Polls/GetVote.php | 2 ++ Backend/Controllers/Polls/GetWinner.php | 2 ++ Backend/Controllers/keyWord/GetKeyWinner.php | 10 +++++++- Backend/Controllers/keyWord/NewKeyWord.php | 16 +++++-------- 18 files changed, 103 insertions(+), 112 deletions(-) delete mode 100644 Backend/Controllers/FileHandler/gameHandler.php diff --git a/Backend/Controllers/Admin/AdminLogin.php b/Backend/Controllers/Admin/AdminLogin.php index 0a66c21..d15b39f 100644 --- a/Backend/Controllers/Admin/AdminLogin.php +++ b/Backend/Controllers/Admin/AdminLogin.php @@ -19,20 +19,18 @@ if(isset($_POST['aLogin'])){ $_SESSION['userName'] = $userName; $_SESSION['admin'] = true; $_SESSION['success'] = "You are now logged in"; - header('location: ../../../Frontend/index.html?login=success'); + http_response_code(200); }else{ session_destroy(); - header('location: ../../../Frontend/index.html?login=failed?reason=password'); - exit(); + echo "Fail to verify password"; + http_response_code(401); } }else{ session_destroy(); - header('location: ../../../Frontend/index.html?login=failed?reason=username'); - exit(); + echo "No user"; + http_response_code(401); } - }else{ - header("location: ../../../Frontend/index.html?error=NoLogin"); - exit(); + http_response_code(400); } \ No newline at end of file diff --git a/Backend/Controllers/Admin/AdminSignup.php b/Backend/Controllers/Admin/AdminSignup.php index 8c7910e..e47089b 100644 --- a/Backend/Controllers/Admin/AdminSignup.php +++ b/Backend/Controllers/Admin/AdminSignup.php @@ -10,17 +10,13 @@ if (isAdmin()){ $admin->user_name = $_POST["newUsername"]; $admin->password = $_POST["newPassword"]; if ($admin->save()){ - header("location: ../../../Frontend/Html/AdminPage.html?success=adminUserWasCreated"); - exit(); + http_response_code(201); }else{ - header("location: ../../../Frontend/Html/AdminPage.html?error=errorWhileSaving"); - exit(); + http_response_code(500); } }else{ - header("location: ../../../Frontend/Html/AdminPage.html?error=input:newAdmin.notSet"); - exit(); + http_response_code(400); } }else{ - header("location: ../../../Frontend/index.html?error=isNotAdministrator"); - exit(); + http_response_code(401); } \ No newline at end of file diff --git a/Backend/Controllers/FileHandler/FileHandler.php b/Backend/Controllers/FileHandler/FileHandler.php index 4e3acd5..cbd439f 100644 --- a/Backend/Controllers/FileHandler/FileHandler.php +++ b/Backend/Controllers/FileHandler/FileHandler.php @@ -15,13 +15,14 @@ function ZipFileHandler(string $gameFileName, string $gameFileTmp){ if(in_array($headerType,$headerTypeMatch)){ $gameFileNewName = uniqid("", true). "." . $fileActualExtGame; if(empty($gameFileName)){ - header("location: ../../../Frontend/index.html?error=emptyFile"); + http_response_code(400); exit(); } rename($gameFileTmp,"../../Games/".$gameFileNewName); return $gameFileNewName; }else{ - header("location: location: ../../../Frontend/index.html?error=Wrong%20File%20Type"); + echo "Wrong file type"; + http_response_code(400); exit(); } return NULL; @@ -42,13 +43,14 @@ function imagesFileHandler(string $thumbnailFileName, string $thumbnailFileTmp){ if(in_array($headerType,$headerTypeMatch)){ $thumbnailFileNewName = uniqid("", true). "." . $fileActualExtThumb; if(empty($thumbnailFileName)){ - header("location: ../../../Frontend/index.html?error=emptyFile"); + http_response_code(400); exit(); } rename($thumbnailFileTmp,"../../../Frontend/images/".$thumbnailFileNewName); return $thumbnailFileNewName; }else{ - header("location: location: ../../../Frontend/index.html?error=Wrong%20File%20Type"); + echo "Wrong file type"; + http_response_code(400); exit(); } return NULL; diff --git a/Backend/Controllers/FileHandler/gameHandler.php b/Backend/Controllers/FileHandler/gameHandler.php deleted file mode 100644 index b3d9bbc..0000000 --- a/Backend/Controllers/FileHandler/gameHandler.php +++ /dev/null @@ -1 +0,0 @@ -img = imagesFileHandler($thumbnailFileName,$thumbnailFileTmp); } $gameData->is_web_Based = $isWebBased; - $gameData->save(); - header("location: ../../../Frontend/index.html?success=UpdatedFiles"); - exit(); + if(!$gameData->save()){ + http_response_code(500); + }else{ + http_response_code(201); + } + }else{ - header("location: ../../../Frontend/index.html?error=FailedUpload"); - exit(); + http_response_code(400); } }else{ - header("location: ../../../Frontend/index.html?error=NoLogin"); - exit(); + http_response_code(401); } \ No newline at end of file diff --git a/Backend/Controllers/FileHandler/upload.php b/Backend/Controllers/FileHandler/upload.php index 4a7d61d..cea1698 100644 --- a/Backend/Controllers/FileHandler/upload.php +++ b/Backend/Controllers/FileHandler/upload.php @@ -52,23 +52,24 @@ if(isLogin()){ $gameData->is_web_Based = $isWebBased; $gameData->save(); $group->gameData()->associate($gameData); - $group->save(); - header("location: ../../../Frontend/index.html?success=UploadedFile"); - exit(); + if(! $group->save()){ + http_response_code(500); + }else{ + http_response_code(201); + } + } }else{ - header("location: ../../../Frontend/group.php?error=UploadFail"); - exit(); + http_response_code(400); } }else{ - header("location: ../../../Frontend/group.php?error=TooManyUploads"); - exit(); + echo "Can only upload one file"; + http_response_code(400); } }else{ - header("location: ../../../Frontend/group.php?error=GameJamHasNotBegun"); - exit(); + echo "Can only upload when the game jam has started"; + http_response_code(400); } }else{ - header("location: ../../../Main.php?error=NoLogin"); - exit(); + http_response_code(401); } \ No newline at end of file diff --git a/Backend/Controllers/GameJam/NewGameJam.php b/Backend/Controllers/GameJam/NewGameJam.php index f4101dd..f8bf5fb 100644 --- a/Backend/Controllers/GameJam/NewGameJam.php +++ b/Backend/Controllers/GameJam/NewGameJam.php @@ -17,18 +17,14 @@ if(isAdmin()){ $gameJam->description = $_POST["description"]; if($gameJam->save()){ - header("location: ../../../Frontend/Html/AdminPage.html?success=UploadedFile"); - exit(); + http_response_code(201); } else{ - header("location: ../../../Frontend/Html/AdminPage.html?error=FailToSaveGameJam"); - exit(); + http_response_code(500); } }else{ - header("location: ../../../Frontend/Html/AdminPage.html?error=FailedToMakeGameJam"); - exit(); + http_response_code(400); } }else{ - header("location: ../../../Frontend/index.html?error=NotAdmin"); - exit(); + http_response_code(401); } \ No newline at end of file diff --git a/Backend/Controllers/GameJam/UpdateGameJam.php b/Backend/Controllers/GameJam/UpdateGameJam.php index 5c4aa23..b63ec20 100644 --- a/Backend/Controllers/GameJam/UpdateGameJam.php +++ b/Backend/Controllers/GameJam/UpdateGameJam.php @@ -22,16 +22,14 @@ if(isAdmin()){ $gameJam->description = $_POST['description']; if ($gameJam->save()) { - header("location: ../../../Frontend/Html/AdminPage.html?success=UpdatedFile"); - exit(); + http_response_code(201); + }else{ + http_response_code(500); } } }else{ - header("location: ../../../Frontend/Html/AdminPage.html?error=FailedToUpdatedGameJam"); - exit(); + http_response_code(400); } - }else{ - header("location: ../../../Frontend/index.html?error=NotAdmin"); - exit(); + http_response_code(401); } diff --git a/Backend/Controllers/Group/Login.php b/Backend/Controllers/Group/Login.php index 292cdb6..3d18dc6 100644 --- a/Backend/Controllers/Group/Login.php +++ b/Backend/Controllers/Group/Login.php @@ -25,26 +25,23 @@ if(isset($_POST['login'])){ $_SESSION['groupName'] = $groupName; $_SESSION['token'] = $token; $_SESSION['success'] = "You are now logged in"; - header('location: ../../../Frontend/index.php?login=success'); - exit(); + //header('location: ../../../Frontend/index.php?login=success'); + //exit(); + http_response_code(200); } else{ session_destroy(); - header('location: ../../../Frontend/index.php?login=failed&?reason=token'); - exit(); + http_response_code(500); } }else{ session_destroy(); - header('location: ../../../Frontend/index.php?login=failed&?reason=password'); - exit(); + http_response_code(401); } - } - else{ + }else{ session_destroy(); - header('location: ../../../Frontend/index.php?login=failed&?reason=group'); - exit(); + http_response_code(400); } diff --git a/Backend/Controllers/Group/ResetPassword.php b/Backend/Controllers/Group/ResetPassword.php index 6b91f2a..4ad3cd7 100644 --- a/Backend/Controllers/Group/ResetPassword.php +++ b/Backend/Controllers/Group/ResetPassword.php @@ -12,19 +12,17 @@ if(isAdmin()){ $password->password = password_hash($_POST['newPassword'], PASSWORD_DEFAULT); echo $password; if(!$password->save()){ - header("location: ../../../Frontend/Html/AdminPage.html?error=FailedSaveResetPassword"); - exit(); + http_response_code(500); + }else{ + http_response_code(201); } }else{ - header("location: ../../../Frontend/Html/AdminPage.html?success=SavedResetPassword"); - exit(); + http_response_code(400); } }else{ - header("location: ../../../Frontend/Html/AdminPage.html?error=FailedToResetPassword"); - exit(); + http_response_code(400); } }else{ - header("location: ../../../Frontend/index.html?error=NotAdmin"); - exit(); + http_response_code(401); } \ No newline at end of file diff --git a/Backend/Controllers/Group/SigningUp.php b/Backend/Controllers/Group/SigningUp.php index fbf1d66..b3cd946 100644 --- a/Backend/Controllers/Group/SigningUp.php +++ b/Backend/Controllers/Group/SigningUp.php @@ -37,19 +37,18 @@ if(isset($_POST['regGroup'])){ $password->remember_token = $token; if(!$password->save()){ - return; + http_response_code(500); + }else{ + http_response_code(201); } $_SESSION['groupName'] = $groupName; $_SESSION['token'] = $token; $_SESSION['success'] = "You are now logged in"; - header("location: ../../../Frontend/index.html?success=GroupRegister"); - exit(); + }else{ - header("location: ../../../Frontend/index.html?error=CouldNotValidatePassword"); - exit(); + http_response_code(400); } }else{ - header("location: ../../../Frontend/index.html?error=FailedRegister"); - exit(); + http_response_code(400); } diff --git a/Backend/Controllers/Group/UpdateGruop.php b/Backend/Controllers/Group/UpdateGruop.php index e54ff05..b96c655 100644 --- a/Backend/Controllers/Group/UpdateGruop.php +++ b/Backend/Controllers/Group/UpdateGruop.php @@ -10,17 +10,17 @@ if(isLogin()){ $group->group_name = $_POST['groupName']; $group->group_amount = $_POST['groupAmount']; $group->game_jam_id = $_POST['gameJamId']; - $group->save(); - header("location: ../../../Frontend/index.html?success=YouHaveUpdated"); - exit(); + if(!$group->save()){ + http_response_code(500); + }else{ + http_response_code(201); + } } }else{ - header("location: ../../../Frontend/index.html?error=CouldNotUpdate"); - exit(); + http_response_code(400); } }else{ - header("location: ../../../Frontend/index.html?error=NotLogin"); - exit(); + http_response_code(401); } diff --git a/Backend/Controllers/Group/UpdatePassword.php b/Backend/Controllers/Group/UpdatePassword.php index b05709e..3bcd2a9 100644 --- a/Backend/Controllers/Group/UpdatePassword.php +++ b/Backend/Controllers/Group/UpdatePassword.php @@ -8,16 +8,16 @@ if(isLogin()){ $password = Password::firstWhere("group_id", groupViaToken($_SESSION["token"])->id); if(passwordValidate($pass = $_POST['password'])){ $password->password = password_hash($pass,PASSWORD_DEFAULT); - $password->save(); - header("location: ../../../Frontend/index.html?success=PasswordUpdated"); - exit(); + if(!$password->save()){ + http_response_code(500); + }else{ + http_response_code(201); + } } }else{ - header("location: ../../../Frontend/index.html?error=CouldNotUpdated"); - exit(); + http_response_code(400); } }else{ - header("location: ../../../Frontend/index.html?error=NotLogin"); - exit(); + http_response_code(401); } diff --git a/Backend/Controllers/Polls/1vote.php b/Backend/Controllers/Polls/1vote.php index 85f00de..04ff428 100644 --- a/Backend/Controllers/Polls/1vote.php +++ b/Backend/Controllers/Polls/1vote.php @@ -14,17 +14,15 @@ if(isset($_POST['1Vote'])){ $vote->points += 1; if(!empty($_POST['comment'])){ $vote->comment = $_POST['comment']; - }else{ - header("location: ../../../Frontend/index.html?error=EmptyField"); - exit(); } - $vote->save(); - header("location: ../../../Frontend/index.html?success=YouHaveVoted"); - exit(); + if(!$vote->save()){ + http_response_code(500); + }else{ + http_response_code(201); + } } }else{ - header("location: ../../../Frontend/index.html?error=YouCantVoted"); - exit(); + http_response_code(400); } diff --git a/Backend/Controllers/Polls/GetVote.php b/Backend/Controllers/Polls/GetVote.php index 22bd5ba..e421407 100644 --- a/Backend/Controllers/Polls/GetVote.php +++ b/Backend/Controllers/Polls/GetVote.php @@ -7,4 +7,6 @@ if(isLogin()){ header('Content-Type: application/json;charset=UTF-8'); echo Vote::where('group_id',groupViaToken($_SESSION['token'])->id)->get()->toJson(JSON_PRETTY_PRINT); +}else{ + http_response_code(401); } diff --git a/Backend/Controllers/Polls/GetWinner.php b/Backend/Controllers/Polls/GetWinner.php index a81710d..3613331 100644 --- a/Backend/Controllers/Polls/GetWinner.php +++ b/Backend/Controllers/Polls/GetWinner.php @@ -28,5 +28,7 @@ if(isAdmin() && isset($_GET['gameJamId'])){ echo $winningGroups->toJson(JSON_PRETTY_PRINT); +}else{ + http_response_code(401); } diff --git a/Backend/Controllers/keyWord/GetKeyWinner.php b/Backend/Controllers/keyWord/GetKeyWinner.php index 1000131..0045d10 100644 --- a/Backend/Controllers/keyWord/GetKeyWinner.php +++ b/Backend/Controllers/keyWord/GetKeyWinner.php @@ -14,11 +14,19 @@ if (!isAdmin()){ $all_group_in_game_jam_id = Group::where("game_jam_id", $game_jam->id)->pluck("id")->toArray(); $find_all_keywords = KeyWord::whereIn("group_id", $all_group_in_game_jam_id)->inRandomOrder()->get(); $game_jam->key_word = $find_all_keywords->first()->key_word; - $game_jam->save(); + if(!$game_jam->save()){ + http_response_code(500); + }else{ + http_response_code(201); + } header("Access-Control-Allow-Methods: GET"); header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept"); header('Content-Type: application/json;charset=UTF-8'); echo $find_all_keywords->pluck("key_word")->toJson(JSON_PRETTY_PRINT); + }else{ + http_response_code(400); } +}else{ + http_response_code(401); } \ No newline at end of file diff --git a/Backend/Controllers/keyWord/NewKeyWord.php b/Backend/Controllers/keyWord/NewKeyWord.php index 26164ea..5049f3b 100644 --- a/Backend/Controllers/keyWord/NewKeyWord.php +++ b/Backend/Controllers/keyWord/NewKeyWord.php @@ -25,23 +25,19 @@ if (isLogin()) { //Try to save it if(!$keyword->save()){ - header("location: ../../../Frontend/index.html?error=FailedToSave"); - exit(); + http_response_code(500); }else{ - header("location: ../../../Frontend/index.html?success=KeyWordSaved"); - exit(); + http_response_code(201); } }else{ - header("location: ../../../Frontend/index.html?error=YouCantSubmitAnyMoreKeyWords"); - exit(); + echo "limited upload reached"; + http_response_code(400); } }else{ - header("location: ../../../Frontend/index.html?error=CouldNotSubmitKeyWord"); - exit(); + http_response_code(400); } }else{ - header("location: ../../../Frontend/index.html?error=NotLogin"); - exit(); + http_response_code(401); }