-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-election.php
38 lines (31 loc) · 1.37 KB
/
run-election.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
session_start();
// Include your database connection file
include('connection.php');
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Retrieve form data
$employeeID = $_POST['EmployeeID'];
$password = $_POST['Password'];
$SectionBatch = $_POST['SectionBatch'];
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
// Sanitize input data before inserting into the database
$employeeID = mysqli_real_escape_string($conn, $employeeID);
$password = mysqli_real_escape_string($conn, $password);
$SectionBatch = mysqli_real_escape_string($conn, $SectionBatch);
// Insert data into the database (replace with your actual table and column names)
$sql = "INSERT INTO election_data (employeeID, password, SectionBatch) VALUES ('$employeeID', '$password', '$SectionBatch')";
$sqlElectionSettings = "INSERT INTO election_settings (SectionBatch, IsActive, IsPaused, showResult, openForApply) VALUES ('$SectionBatch', 0, 0, 0, 0)";
mysqli_query($conn, $sqlElectionSettings);
if (mysqli_query($conn, $sql)) {
$_SESSION['employeeID'] = $employeeID;
$_SESSION['SectionBatch'] = $SectionBatch;
header('location:dashboard.php');
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
// Close the database connection
mysqli_close($conn);
}