I am trying to limit form entries to once per day by searching table for records with same email and submit date of today:
table name: customer
field name: email
field name: submitdate
The existing application uses a series of includes so I was hoping to add a "function" or include that does this validation, terminates the form submission and takes user to an error page if there is already a record for that day.
I am having no success with the following code (among other things, there might be a date formatting issue because table contains date like: 2011-09-11 20:38:31 so I guess it would have to trim that to find a match)
// Get a specific result from the database_table
$result = mysql_query("SELECT * FROM contact_requests
WHERE email='$email'") or die(mysql_error());
// get the first and loop until all entries are found with the above result
while($row = mysql_fetch_array($result))
// compare the entry from the form to the result of the sql_table & the date of entry into table
if($email == $row['email'] && $submitdate == $row['DATETIME'])
I am trying to add the code to an existing class include but I'm an amateur... please help...