insertDB($query); } function queryRecruits() { $db = connectDB(); //Because we are filling the form from the DB, the post also grabs the name= at the end of the name. //We find where name starts, and get the first section of the string which contains just the name. //$recruit = getRecruit(); $recruit = getRecruit(); $pos = strpos($recruit, "name="); $name = substr($recruit, 0, $pos); foreach ($db->query("SELECT name, vote_count, creation_date FROM recruit WHERE name='" . $name . "'") as $row) { echo "<font color='white'>" . $row['name'] . ' Vote Count:' . $row['vote_count'] . ' Start Date:' . $row['creation_date'] . '<br />'; } } insertVote(); ?> <!DOCTYPE html> <html> <head> <title>Recruit Result</title> <style> html,body { height: 100%; margin: 0; padding: 0; } p { font-family: arial; color: #efefef; }
<?php require_once "functions.php"; //kontrollin, kas kasutaja ei ole sisseloginud if (!isset($_SESSION["id_from_db"])) { header("Location: login.php"); } //login välja if (isset($_GET["logout"])) { //kustutab kõik sessiooni muutujad session_destroy(); header("Location: login.php"); } //punktide andmiseks if (isset($_GET["vote"])) { insertVote($_GET["country_id"], $_GET["points"]); } $song_list = getData(); ?> <p> Sisse logitud kasutajaga <?php echo $_SESSION["user_email"]; ?> <a href="?logout=1"> Logi välja</a> </p> <h1>Eurovision Song Contest</h1> <table border= 1> <tr> <th>id</th> <th>Country</th>