Edmhar Edmhar - 2 years ago 176
SQL Question

Change the value after expiration date PHP MYSQL

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.


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

if after 30days the status will change to
if after 90days it will change to

This my code for
but I don't know how to code the

$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 .'"/>';

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download