我有不同的事件,其中用户可以注册。这些事件都有自己的日期和时间安排。如何添加一种自动限制用户注册的时间限制?
例如,我在2012年3月10日安排了一个活动。用户只能在2012年3月9日之前注册该活动。
我的事件表包含以下字段:
eventID/eventName/eventTime/eventDate/eventCapacity/eventDescription
谢谢你的帮忙!
发布于 2012-03-05 14:20:18
使用eventTime/eventDate参数获取事件,并使用datediff检查今天的日期是否小于或未使用function.if date是否大于重用接受。
发布于 2012-03-05 13:49:17
检索事件日期和当前日期,并使用PHP date对象计算差值
mysql_connect("localhost", "root", "");
mysql_select_db("myDb")
$query="SELECT * FROM events WHERE eventName='$eventName' ";
$result=mysql_query($query);
$row=mysql_fetch_array($result);
$currentTime= new DateTime("now UTC");
$eventTime=new DateTime($row['thisEventDate']);
$interval=$eventTime->diff($currentTime);
$days=$interval->format('%d');
if($days<=1) {
print "sorry too late, we're sold out";
}
else {
//allow for registration fields.
}发布于 2012-03-05 13:49:45
通过比较当前日期和期望日期,或者取当前日期和期望日期的差值,并相应地将HTML表单显示到PHP if循环中
示例
if($days<=1) {
echo "where were you wen i asked you to do so!!! ";
}
else {
<form>
field1
field2
...
</form>
}这里,$days表示日期的差异
https://stackoverflow.com/questions/9562122
复制相似问题