473,396 Members | 1,945 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Registration date

I am having issues with my registration date.
I need to capture the registration date of a user and compute the expiry date but my script is not capturing both the date and expiry date.

I have posted my scripts here for you.

Please help.

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. if (isset($_POST['Submit'])) {
  4. //$Bday  = date("dd-mm-yyyy");
  5. include "dbCon.php";
  6.  
  7. $EmailAd = $_POST['EmailAd'];
  8. $Password = $_POST['Password'];
  9. $Name = $_POST['Name'];
  10. $Age = $_POST['Age'];
  11. $Gender = $_POST['Gender'];
  12. $Bday = $_POST['Bday'];
  13. $Phone = $_POST['Phone'];
  14. $College = $_POST['College'];
  15. $Course = $_POST['Course'];
  16. $Yr = $_POST['Yr'];
  17. $UserType= $_POST['UserType'];
  18. $Address= $_POST['Address'];
  19. $Interest = $_POST['Interest'];
  20. $Affiliation = $_POST['Affiliation'];
  21. $Schedule = $_POST['Schedule'];
  22. $About = $_POST['About'];
  23. $Who = $_POST['Who'];
  24. $now=date ("Y-m-d"); //store current date to a variable. this is used for scratch card expiration processes
  25. $exp=date ("Y-m-d", mktime (0,0,0,date("m")+12,(date("d")+0),date("Y"))); //set expiry date of user to 12months the date of account creation
  26.  
  27.  
  28. $query = mysql_query("INSERT into user (EmailAd, Password, Name, Age, Gender, Bday, Phone, College, Course, Yr, UserType, Address, Interest, Affiliation, Schedule, About, Who)
  29.                     VALUES('$EmailAd', '$Password', '$Name', '$Age', '$Gender', '$Bday', '$Phone', '$College', '$Course', '$Yr', '$UserType', '$Address', '$Interest', '$Affiliation', '$Schedule', '$About', '$Who', Regdate='$now',  expire='$exp'))");
  30.  
  31. // $sql= "INSERT INTO user SET Regdate='$now',  expire='$exp'";
  32.  
  33. if ($query) {        
  34.     session_start();
  35.     $_SESSION['EmailAd'] = $_POST['EmailAd'];                                  
  36.     header ('Location: registerSuccess.php');
  37.     }
  38. else {
  39.     echo ('Failed to Input Data');
  40.     }
  41. }
  42. ?>
  43.  
Jan 6 '11 #1

✓ answered by HaLo2FrEeEk

I'm not sure why you sent me a PM as well as posting it here, but I'll just copy my reply to the PM here:

I assume that the error is happening on lines 25 and 26. The way you're getting the date is wrong. To get the current time, you need only to use the method time(), this will return a timestamp that can be used in the date() function. To get a time in the future you have a few options. You can either get the current time with time() and add the number of seconds until the future date (in your case, 12 months in advance, so it would be 60 * 60 * 24 * 365 = 31536000), or use the strtotime() function, which has the following syntax:

$future = strtotime("+1 year");

or

$future = strtotime("+12 months");

Or basically any combination that would evaluate to 1 year in the future, so 1 year, 12 months, 52 weeks, or 365 days. This will also return a timestamp for the future date. I recommend strtotime().

I hope I've helped, please let me know if you need something explained and I'll do my best.

3 4234
HaLo2FrEeEk
404 256MB
I'm not sure why you sent me a PM as well as posting it here, but I'll just copy my reply to the PM here:

I assume that the error is happening on lines 25 and 26. The way you're getting the date is wrong. To get the current time, you need only to use the method time(), this will return a timestamp that can be used in the date() function. To get a time in the future you have a few options. You can either get the current time with time() and add the number of seconds until the future date (in your case, 12 months in advance, so it would be 60 * 60 * 24 * 365 = 31536000), or use the strtotime() function, which has the following syntax:

$future = strtotime("+1 year");

or

$future = strtotime("+12 months");

Or basically any combination that would evaluate to 1 year in the future, so 1 year, 12 months, 52 weeks, or 365 days. This will also return a timestamp for the future date. I recommend strtotime().

I hope I've helped, please let me know if you need something explained and I'll do my best.
Jan 7 '11 #2
Thanks.
Please give me a beta explanation.
I need to capture the current date to the database.
And also add 12 months to it and save the result to the database in Y-m-d format
Jan 7 '11 #3
HaLo2FrEeEk
404 256MB
I not only gave you the exact explanation as to what you needed to do, I gave you the CODE for what you need. Storing a date in a database in "y-m-d" format is a very poor and inefficient use of database space. A timestamp is a universal measurement of time that (for now) uses a 32-bit integer to keep track of the number of seconds that have passed since the unix epoch, which is 1/1/1970 at 12:00:00 am. Since this number is universal, it's supported in nearly all programming languages, including PHP.

I TOLD you what you needed to do and I GAVE you the code to do it, now do a little work yourself and figure it out. We're not here to do things for you, we're here to help you learn how to do them yourself.

Seriously, this is frustrating. Go back, read my reply, pay attention, and think about exactly what I said.

http://php.net/time
http://php.net/date
Jan 7 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: dave | last post by:
How would I go about creating the simplest routine in VB 6.0 to have a user E-Mail me the application name, date installed and his/her E-Mail Address ?
3
by: Jason | last post by:
Hi all, Merry Christmas! I would like to have trial period for my .NET application and let user to enter S/N for registration. I would like to ask how can we store the registration status of...
12
by: Etienne | last post by:
Hi, I'm writing an activation system for a software, which allows a 15 days grace period. Now the question is... how can I store the date? It has to be kept even if the software is reinstalled, and...
0
by: Paul Boddie | last post by:
EuroPython is the European Python and Zope Conference, taking place this year in Vilnius, Lithuania from Monday 9th July to Wednesday 11th July. The last day of EuroPython's early registration...
1
by: danibecr | last post by:
I'm trying to make a table that will daily count the records imported and save them to a seperate table along with the date imported. But as of now after all the processing is complete I delete...
3
by: satishknight | last post by:
Hi, Can some one tell me how to change the validation sequence for the code pasted below, actually what I want it when any one enters the wrong login information (already registered users) then it...
4
peeaurjee
by: peeaurjee | last post by:
Hello, I have a query containing Serial, Name, Residence Visa Expiry Date in MS Access 2003. I need to put Residence Visa Registration Date in other field and that would be in reverse I mean 3...
5
by: jerrydigital | last post by:
Hi, I have a registration form that uses the javascript validation code I have posted below. I am trying to verify that the user enters a birthdate in the format 01/11/1999 Anyone know how I...
9
by: happyse27 | last post by:
Hi All, In perl script(item b below) where we check if html registration form are filled in properly without blank with the necessary fields, how to prompt users that the field are incomplete...
3
by: tutusaint | last post by:
I have a registration page which captures details including birth date and registration date. The birth date and Date is not captured in mysql database. Please help Registration.php <?php if...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.