Exemplo n.º 1
0
$result2 = $sql2->setFetchMode(PDO::FETCH_ASSOC);
$result2 = $sql2->fetchAll();
for ($j = 0; $j < count($result2); $j++) {
    $manifestos[$j] = $result2[$j]['manifesto'];
    $manifestos_id[$j] = $result2[$j]['manifesto_id'];
}
$no_of_manifesto_point = count($manifestos);
$sql3 = $connection1->prepare("SELECT post, post_key FROM posts WHERE post_id='{$user_post_id}'");
$sql3->execute();
$result3 = $sql3->setFetchMode(PDO::FETCH_ASSOC);
$result3 = $sql3->fetchAll();
$user_contestant_post = $result3[0]["post"];
$contestant_post_pin = $result3[0]["post_key"];
$sql4 = $connection1->prepare("SELECT election_name FROM election WHERE election_id='{$election_id_here}'");
$sql4->execute();
$result4 = $sql4->setFetchMode(PDO::FETCH_ASSOC);
$result4 = $sql4->fetchAll();
$contestant_election_name = $result4[0]["election_name"];
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if (isset($_POST["delete"])) {
        $sqm1 = "DELETE FROM manifesto WHERE contestant_id='{$user_contestant_id}'";
        $connection1->exec($sqm1);
        $sqm2 = "DELETE FROM contestants WHERE contestant_id='{$user_contestant_id}'";
        $connection1->exec($sqm2);
        $key = rand(1, 9) . rand(10, 99) . rand(10, 99) . rand(1000, 9999) . $_SESSION['election_id'] . rand(10000, 99999) . rand(100, 999);
        header("Location:election_detailsNews.php?key=" . $key);
    }
}
//checking for the link vote
$hasvoted = hasvoted(user_id($myemail), $election_id_here);
';">
                                          </div>
                                        </div>
                                    </form>
                            </div>
                        </fieldset>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
//lets use php to determine if the vote_link should be active
<?php 
$activate_vote = 0;
if (concluded($result5[0]["election_start_date"], $result5[0]["election_time_from"], 0) && !concluded($result5[0]["election_end_date"], $result5[0]["election_time_to"], 0) && hasvoted($user_id, $contestant_election_id) == 0) {
    $activate_vote = 1;
}
?>
//lets do the script
<script type="text/javascript">
    var activate_vote = 0;
     activate_vote =<?php 
echo $activate_vote;
?>
 ;
    if( activate_vote == 1 )
    {
        var vote_link = $('#vote_link');
        vote_link.attr({'href':'voting.php'});
    }