Forum Moderators: coopster

Message Too Old, No Replies

only enter results if date has passed

         

nshack31

12:42 pm on Feb 3, 2005 (gmt 0)

10+ Year Member



I have a PHP match result system. I do not want the user to enter the result if the date has not passed. If the date has passed then $played = 'Yes', If not then $played = 'No'.

I read the date and time values of the match from the database. I then need to validate them. I could use the system clock BUT somebody could simply move the date on their machine to beat the system! Is there any other way to solve this? Thankyou

dmmh

1:20 pm on Feb 3, 2005 (gmt 0)

10+ Year Member



I think you need to be more specific, to me this didnt make sense...at all :)

nshack31

2:29 pm on Feb 3, 2005 (gmt 0)

10+ Year Member



ok imagine a football league website. Lets say a game is arranged to be played on 4th feb at 7.00pm.

When the game is played, you need to enter the result in the database via a php page.

I wish to make it so that the result cannot be entered until the date has passed!

So I call 4th feb @ 7pm from the DB and need to validate it to see if the date has passed. If it has then you can enter the result, if not then you cant enter the result.

What do i validate 4th feb 7pm against? If i use the system clock then people could move their clock/date forward and enter the match result!

dmmh

12:56 am on Feb 4, 2005 (gmt 0)

10+ Year Member



I think you may find this usefull:

[nl3.php.net...]

returns the local (server) system date if you dont pass it a string :)

nshack31

12:15 pm on Feb 4, 2005 (gmt 0)

10+ Year Member



ah super thanks! i eventually ended up with this..

$date_to_compar = date("g:i a Y-m-d", mktime(date("$hour"), date("$minute"), date("$ampm"), date("$month"), date("$day"), date("$year"))); 

There is an error with the "ampm" part. When i echo $date_to_compar the time is ALWAYS am when it should be pm. Is there an error in my code?

nshack31

1:49 pm on Feb 4, 2005 (gmt 0)

10+ Year Member



that last explination was a bit cvague to say the least, here is my code..

first i set the current date


$today = date("m-d-Y", mktime(date("m"), date("d"), date("Y")));

then i read the date from the DB


$day = $row['day'];
$year = $row['year'];
$hour = $row['hour'];

$date_to_compar = date("m-d-Y", mktime(0, 0, 0, $month, $day, $year));

i then validate the date from the DB to the current date


if($today >= $date_to_compar)
{
$played = 'Yes';
}

It works great but how do I add a time validation to this?