So I am currently working for Online Election system for my school project and I am having a hard time how to set a start and end time for election. I have a date/time picker for start time and for end time and then I want the value of dtpicker to save in my database and I want to have a countdown based on the time on my database and if the election start it will display the voting page and if the election ends it will redirect to results. How can I do that. I've been a lot of threads but they did not solve my problem. Could you please help me? Do you have any idea or suggest a website related to my problem? I'm stuck on this problem for 3 days. Any help would be greatly appreciated.
---UPDATE---
so here is my code below:
<?php
$con = mysql_connect("localhost","root","vertrigo");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("db_voting", $con);
$result = mysql_query("SELECT * FROM time WHERE time_ID = 1");
$numrow = mysql_num_rows($result);
if ($numrow == 0)
{
die('No election found.');
}
$row = mysql_fetch_row($result);
$startdate = date_format(date_create($row[1]), 'm/d/Y H:i:s');
echo "Voting will start: " . $startdate. "<br />";
$closedate = date_format(date_create($row[2]), 'm/d/Y H:i:s');
echo "Voting will end: " . $closedate;
?>
<p>Time Left:
<script language="JavaScript">
TargetDate = "<?php echo $closedate ?>";
BackColor = "palegreen";
ForeColor = "navy";
CountActive = true;
CountStepper = -1;
LeadingZero = true;
DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
FinishMessage = "Voting has Ended";
</script>
<script language="JavaScript" src="countdown.js"></script>
so what i am trying to do is whenever the election ends it will redirect to result if not then it will display the voting page. should I use if else statement? I am so sorry, I am still a noob about this. Could you please help me out.?