Reputation: 650
I'm beginner in PHP MySQL, I have system that after you register/add the customer information it will change the status after 30 days.
Scenario
In my add customer page, I have forms like Date Start, Date Expiration and Status.
Date Start - automatically set the date today
Expiration - Automatically set the Date Start + 30 days
Expiration2 - Automatically set the Expiration date + 90 days
Status - Status of the customer (if newly registered the status value will be FRESH
if after 30days the status will change to INACTIVE
if after 90days it will change to DORMANT
.
This my code for dateStart
and dateExpired
, dateExpired2
but I don't know how to code the status
process.
$dateStart= Date('Y-m-d');
$dateExpired = date('Y-m-d', strtotime($dateStart. ' + 30 days'));
$dateExpired2 = date('Y-m-d', strtotime($dateExpired2. ' + 90days'));
echo '<input type="text" name= "dateStart" value="'. $dateStart.'"/>';
echo '<input type="text" name= "dateExpired" value="'. $dateExpired .'"/>';
Upvotes: 2
Views: 4653
Reputation: 11987
Trigger a cron job.
I have added following images , refer them
I have added a cron which runs once in a day. and in your server, it looks like this.
Upvotes: 3
Reputation: 94
If you run a script like this at a scheduled interval, it can automatically update your user's status':
$dateStart= date('Y-m-d');
$dateExpired = date('Y-m-d', strtotime($dateStart. ' + 30 days'));
$dateExpired2 = date('Y-m-d', strtotime($dateStart. ' + 90days'));
$status = "FRESH";
if(strtotime($dateStart)<strtotime('-30 days')){
$status = "INACTIVE";
}
if(strtotime($dateStart)<strtotime('-90 days')){
$status = "DORMANT";
}
//Run sql update query to set status
See here for sql update query
Upvotes: 2