Forum Moderators: coopster

Message Too Old, No Replies

PHP+SQL Page expiration?

         

Menekali

8:45 pm on Oct 18, 2004 (gmt 0)

10+ Year Member



Hey all. Thanks in advance for the help, this site is also so helpful, and just good for reading material sometimes as well to learn.

What i have going on, is a client who needs sort of a payment area. Someone signs up, they pay, and after that they have acess to a certain page for 30 days. After the 30 days, they need to be prompted to pay another 30 days and restricted acess to this area. How would this be possible? The payment i have worked out, is done with paypal. But other than that the rest im confused about.

Someone told me once, that i could use a function in SQL that would count down each day, and just make some sort of comparison with the php. I feel like maybe im losing my self here heh. Anyone understand, and know what i could possibly do, or maybe even a premade script i could toy with? Thanks alot in advance as usual!

crashomon

8:51 pm on Oct 18, 2004 (gmt 0)

10+ Year Member



Well, you can use cookies to set expiration dates (this day +30) and if the cookie has expired, then send to 'autobill' page.

HTH

Patrick

ergophobe

9:50 pm on Oct 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I wouldn't use cookies for this. What if the user clears his cookie cache? He'll be told he needs to pay again.

What you want to do is basically this

- when someone pays, record the timestamp in the mysql DB.
- when he logs in, find out the current time and compare it to the timestamp in the DB
- if the time difference is more than 30 days, send to a resubscribe page.

Better, though, would be to set the expiration date in the DB. Why?

- you only calculate the time difference when someone adds time which is a less common event than just logging in (tiny reduction in server load).
- more importantly, you can more easily handle situations where someone prepays and can more easily offer subscription options like 1 month, 3 month, 1 year.

From what you say about your ability, I'm not sure this will help, but start here:

php date and time functions [us2.php.net]
mysql date and time functions [dev.mysql.com]

Menekali

3:40 am on Oct 21, 2004 (gmt 0)

10+ Year Member



Thank you very much for the replies guys. Ergophobe thank you even more for the links. Does anyone know of any pre-compiled scripts with this type of thing i could learn from? I want ot code this my self, without resorting to other code, but to learn is fun. Any other insight would help too, such as code that i could possibly use. Thanks so much guys, and thanks to the others in advance.