Keyword now gets its data from session, made a error pages display

This commit is contained in:
neerholt 2021-03-08 10:29:11 +01:00
parent 5d0e60cd9d
commit 913fdae646
3 changed files with 26 additions and 27 deletions

View File

@ -3,34 +3,36 @@ require "../bootstrap.php";
use Backend\Models\Group;
use Backend\Models\KeyWord;
session_start();
if (session_status() === PHP_SESSION_ACTIVE) {
if(isset($_POST['submitKeyWord'])){
//Find the group id
$group = Group::find($_SESSION['groupId']);
if(isset($_POST['submitKeyWord'])){
//Find the group id
$group = Group::find($_POST['group_id']);
//if statement to find out if the group have use all their keyWords
if(KeyWord::where('group_id', $group->id)->count()<$group->groupAmount){
//if statement to find out if the group have use all their keyWords
if(KeyWord::where('group_id', $group->id)->count()<$group->groupAmount){
//Make a new keyword[Only to be used if you need to make a new of something]
$keyword = new KeyWord();
//Make a new keyword[Only to be used if you need to make a new of something]
$keyword = new KeyWord();
//Take the keyWord the user typed and set it equal to the keyword valuable
$keyword->keyWord = $_POST['key_word'];
//Take the keyWord the user typed and set it equal to the keyword valuable
$keyword->keyWord = $_POST['key_word'];
//Make foreign key from the groups table to the keyWords table
$keyword->group()->associate($group);
//Make foreign key from the groups table to the keyWords table
$keyword->group()->associate($group);
//Try to save it
if(!$keyword->save()){
header("location: ../Frontend/index.php?created=failed");
}else{
header("location: ../Frontend/index.php?created=success");
//Try to save it
if(!$keyword->save()){
header("location: ../Frontend/index.php?created=failed");
}else{
header("location: ../Frontend/index.php?created=success");
}
}
}
//TODO make toast feedback
//TODO make toast feedback
}
}else{
header("location: ../Frontend/index.php?login=notLoggein");
}

View File

@ -1,8 +1,3 @@
<?php
/*
require "../bootstrap.php";
*/
?>
<!DOCTYPE html>
<html lang="en">
@ -15,7 +10,6 @@ require "../bootstrap.php";
<form action="../Backend/keyWordsRemaining.php" method="POST">
<input type="text" name="key_word" placeholder="key word">
<input type="number" name="group_id" placeholder="group id">
<input type="submit" name="submitKeyWord" value="Submit">
</form>

3
Frontend/index.php Normal file
View File

@ -0,0 +1,3 @@
<?php
print_r($_GET);