} if ($valid_email_count > 1) { $errors[] = 'Please upload a csv file containing email addresses'; } } } if (empty($errors)) { $not_invited = 0; $select_query = "SELECT email, user_id FROM users"; $smh = $connection1->prepare($select_query); if ($smh->execute()) { $result = $smh->fetchAll(PDO::FETCH_ASSOC); } $fields = array('user_id', 'email'); $valid_voters = csv_valid_voters($csvFields, $result, $fields); $valid_users = csv_valid_voters($csvFields, $result, $fields, 1); if (is_array($valid_voters) && !empty($valid_voters)) { for ($i = 0; $i < count($valid_voters); $i++) { $valid_voters[$i]['election_id'] = $election_id; } foreach ($valid_voters as $voter) { if ($request_members && in_array($voter['user_id'], $request_members)) { $display_request[] = getAllMembers('users', array('email'), array('user_id', '=', $voter['user_id']), 1)[0]; $request_count++; } elseif ($invite_members && in_array($voter['user_id'], $invite_members)) { $display_invited[] = getAllMembers('users', array('email'), array('user_id', '=', $voter['user_id']), 1)[0]; $invite_count++; } elseif ($joined_members && in_array($voter['user_id'], $joined_members)) { $display_joined[] = getAllMembers('users', array('email'), array('user_id', '=', $voter['user_id']), 1)[0]; $joined_count++; } else {
foreach ($posts as $key => $value) { $posts_key_value = $key; $posts_post_value = $value; $last_election_id_value = $last_election_id; $sql->execute(); } $last_post_id = $connection1->lastInsertId(); //csv module if (empty($errors) && $csv == 'active') { $select_query = "SELECT email, user_id FROM users"; $smh = $connection1->prepare($select_query); if ($smh->execute()) { $result = $smh->fetchAll(PDO::FETCH_ASSOC); } $fields = array('user_id', 'email'); $valid_voters_id = csv_valid_voters($csvFields, $result, $fields); $_SESSION['csv'] = $csvArray; if ($valid_voters_id) { $query_electionId = "SELECT election_id,election_name FROM election WHERE election_pin = '{$election_pin}'"; foreach ($result = $connection1->query($query_electionId) as $election) { $election_id = $election['election_id']; $election_name = $election['election_name']; } $result->closeCursor(); for ($i = 0; $i < count($valid_voters_id); $i++) { $valid_voters_id[$i]['election_id'] = $election_id; } $user_id = user_id($myemail); //get admin details for mail sending $administrator = getAllMembers('users', ['*'], ['user_id', '=', $user_id])[0]; $sender_name = strtoupper($administrator['fname']) . " " . $administrator['lname'];