Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9190749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:32:00+00:00 2026-06-17T20:32:00+00:00

I am creating a user registration system with mysql and php and added a

  • 0

I am creating a user registration system with mysql and php and added a column to user table called ‘date_expires’ ( with DATE NOT NULL) to make registered users’ registration date to expire. With my form users can select their registration period. Eg: 1 year, 2 year, 3 year. etc. I have got the value of registration period when user submitting the form.. like this

$registrationPeriod = $_POST['registration_period]; 

My problem is how I insert expire date with above value to my user table?

I am trying to insert data to the user table but confusing how I do it with ‘date_expires’ column.

This is my code so far…

$q = "INSERT INTO users (username, email, pass, first_name, last_name, date_expires) 
      VALUES ('$u', '$e', '$p, '$fn', '$ln', ????????????? )";

hope someone help me out about this..
thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:32:02+00:00Added an answer on June 17, 2026 at 8:32 pm

    If your $_POST['registration_period'] comes in as 1 year, 2 year… Then you can most easily strip off the integer value and perform the date calcualtion in MySQL like NOW() + INTERVAL n YEAR where n is the number.

    // Extract it from the registration_period
    // Since it is formatted as "n years" with a space between,
    // we can split the string on the space.  list() assigns an array (returned from explode())
    // to individual variables. Since we only actually need one of them (the number), 
    // we can throw away the second (which is the string "years") by just giving list() one variable
    // It still needs a placeholder for the second though, hence the extra comma.
    list($years,) = explode(" ", $_POST['registration_period']);
    // Make sure it is an int to protect against SQL injection...
    $years = intval($years);
    

    In your query, substitute the number into the date calculation in the VALUES () list:

    INSERT INTO users (.......) VALUES (....., (NOW() + INTERVAL $years YEAR));
    

    Please consider switching to an API which supports prepared statements, like MySQLi or PDO. We can only hope and assume that all your query input variables have been correctly sanitized and filtered against SQL injection in your query’s current form.

    $u = mysql_real_escape_string($_POST['u']);
    $e = mysql_real_escape_string($_POST['e']);
    // etc for all query vars...
    

    (More info on list()

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are creating a user login and registration system and have decided to bypass
Hello I've got another question. I am creating an administration system. I added registration
I am creating an user registration form using jsp,in which there is an option
I have such view that handles user registration. After creating new user i want
I'm creating a registration form using validation inside the User model such as validates_confirmation_of
We are creating a new site using ASP.NET membership provider for user registration and
I think creating a simple user-registration on Orchard CMS should be easy? What I
I am creating an app that accept user info for registration but I was
I'm creating a registration form. The user enters the username and password, and presses
I am looking for some suggestions for creating a User Profile System . I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.