It seems your question is really an HTML/Javascript question and not PHP/SQL.
Because at first glance I would say change the HTML with Javascript so that they cant submit the form.
document.getElementById("myform").action = "";
... would prevent submitting. There are many ways, including switching the form
to a div
:
document.getElementById("myform").setAttribute("type","div");
Or, remove the submit button from display so they cant click on it:
document.getElementById("mysubmit").style.display="none";
EDIT: oh and i completely forgot the obvious way, use form validation. This way they cant park on the URL until after wednesday and still submit in HTML
<form ... onsubmit="return validateForm()">
Just write the javascript function validateForm
(similar to the php below) to return false to cancel the submit. I dont like giving w3school links but here is a nice clean example: http://www.w3schools.com/js/js_form_validation.asp
Anyhow, there are many more ways. Just do which ever one on the right day, use javascript's new Date().getDay()
and new Date().getHours()
to determine when.
(this is also an example of the two main ways to change an element's attributes).
I guess this doesn't stop them from submitting directly from the address line, which in case, you would need to edit your PHP, use the Date()
object:
$day = Date("w");
if ( $day == 4 || $day == 5 ) {
$time = Date("G");
if ( $day != 5 || $time < 18 ) {
if (!mysql_query($sql,$con)) die('Error: ' . mysql_error());
}
}
I would suggest to do both, a HTML/Javascript way of controlling it with the same control built into your server.