Game-Jaming/Backend/Controllers/Polls/1vote.php

36 lines
750 B
PHP

<?php
use Backend\Models\Group;
use Backend\Models\Vote;
require_once "../../../bootstrap.php";
require_once "Vote.php";
if(isset($_POST['1Vote'])){
if(VoteCheck($_POST['groupId'])){
$vote = new Vote();
$vote->group()->associate(Group::find($_POST['groupId']));
$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();
}
}else{
header("location: ../../../Frontend/index.html?error=YouCantVoted");
exit();
}