<?php

include 'session.php';
include_once "connection.php";
include_once "database.php";
include_once "function.php";
$date_diff = '';
$contestant_user_id = $election_id_here = $joined = "";
$key = $_GET['key'];
$contestant_user_id = unwrap($key);
$election_id_here = $_SESSION["election_id_view"];
$sql1 = $connection1->prepare("SELECT contestant_id, picture_name, citation_name, post_id, nickname, election_id FROM contestants WHERE user_id='{$contestant_user_id}' AND election_id='{$election_id_here}'");
$sql1->execute();
$result1 = $sql1->setFetchMode(PDO::FETCH_ASSOC);
$result1 = $sql1->fetchAll();
$joined = joined_id(user_id($myemail), $election_id_here);
if (empty($result1) && strlen($_SESSION["election_id"]) != 1) {
    header("Location:postnews.php?key=" . $_SESSION["election_id"]);
} elseif (empty($result1) && strlen($_SESSION["election_id"]) == 1) {
    header("Location:election_detailsNews.php?key=" . $_SESSION["election_key"]);
}
//Declaring images and citation directory
$images_dir = "../images/contestants/";
$citation_dir = "../contestant_citation/";
//Declaring variables
$contestant_fullname = $contestant_election_name = "";
$contestant_id = $contestant_nickname = $contestant_email = $contestant_phoneno = $contestant_post = $contestant_picture = $contestant_post_id = $contestant_citation = "";
$manifestos = array();
$sql = $connection1->prepare("SELECT fname, lname, email, phone FROM users WHERE user_id='{$contestant_user_id}'");
$sql->execute();
$result = $sql->setFetchMode(PDO::FETCH_ASSOC);
Example #2
0
                    </div>';
    }
    //push the display of this post into string_array
    array_push($string_array, $string);
    array_push($string_result_array, $string_result);
    //the loop picks the next post till all post are picked
}
$contestant_id = "";
$last_id = $joined_id = "";
$message = $hasvoted = $message1 = "";
$last_vote_id = $last_id = 0;
$hasvoted = hasvoted(user_id($myemail), $election_id);
if ($hasvoted == 0) {
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        for ($i = 0; $i < count($superIndex); $i++) {
            if (isset($_POST[removeSpace($superIndex[$i])])) {
                $contestant_id = $_POST[removeSpace($superIndex[$i])];
                $last_id = incrementContestantVote($contestant_id);
            }
        }
    }
    if ($last_id !== 0) {
        $joined_id = joined_id(user_id($myemail), $_SESSION["election_id_view"]);
        $sql = "UPDATE joined SET has_voted= 1 WHERE joined_id='{$joined_id}'";
        $connection1->exec($sql);
        $last_vote_id = $connection1->lastInsertId();
        //        $message1 = "You have have successfully cast your vote thanks for using E-voting";
        header("Location:../html/electionResult.php");
    }
}
//working on the nav bar