Registration and Expiration Date in PHP and MySQL

Hey Technoz, In this tutorial we are going to learn how to create automatic registration and expiration date in php and mysql. Websites containing products required registration and expiration date. So database administrator can not handle huge amount of user’s  registration and expiration date. To make it reliable we can write the code so that we can easily create individual user’s expiration date in php and mysql can manage accordingly.

Creating database

A database need to be create to store the information about Registration and Expiration Date

So lets create the database by using following queries. The following SQL create expiration table which consist of  firstname, lastname, email, registerdate and expirationdate columns.

Dumping data for table ‘expiration’

Now lets insert some records by using following queries.

First, To make it convenient, We will create a new PHP file for database configuration named dbconfig.php  that holds all configured parameters:

 

Registration and Expiration Date in PHP and MySQL

The following code index.php   is used to build user interface of Registration and Expiration Date in PHP and MySQL.

  1. First create a form so that user can able to register.
  2. Then take the user’s data by $_POST method and store it in the database by using SQL query.
  3. Fetch the current date by using date(“Y/m/d”) and store it as registration date.
  4. To add one year to the current date use date(‘Y/m/d’, strtotime(‘+1 years’)) store it as expiry date.
  5. Compare current date and expiry date using if(strtotime(date(“Y/m/d”)) < strtotime($date2)) if current date is lesser than expiry then status is active else expired.

Now, its time to do CSS of the above code to make User Interface looks pretty.

By using following form user can able to register and simultaneously registration and expiration date in php will run and dates will set in mysql.

The glimpse of the above code is in following snapshot.

Registration and Expiration Date in PHP and MySQL

After successfully register you can able to view the previous entries. As well as can able to view whether the current status is active or Expired.

Registration and Expiration Date in PHP and MySQL

In this tutorial we have learn how to create automatic registration and expiration date in php and mysql.

If you have any doubts regarding to this tutorial feel free to ask in the comment section below.

To catch even more knowledgeable and easy understandable tutorials please subscribe to get email notification.

Download Source Code

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.