...

View Full Version : Create random password every 48 hours, email it automatically



Lithium.
05-27-2011, 05:11 AM
Hey everybody :)

I've been trying to do this for a while but haven't got round to nailing it and now with my workload at work and university, it doesn't look like I'll get round to doing it so I would greatly appreciate any help you could give me!

I have information on my website that contains important information. At the moment, it is protected using a small (probably insecure) script that I found online.

Ideally, I would like there to be one login page just asking for a password before you can access the information.

Here's the hard part: I would like the password to be randomly generated. Then, after 48 hours, a new password would be generated and sent via email to select email addresses.

Would this be possible?

Thanks a lot everyone :thumbsup:

bullant
05-27-2011, 05:19 AM
Would this be possible?
Yep, no problem.

Create a php script to generate a random password, update the database with it and then to send out the emails with the new password.

Then set up a cron job on your web server to run that script automatically every 48 hours.

Lithium.
05-27-2011, 06:19 AM
Yep, no problem.

Create a php script to generate a random password, update the database with it and then to send out the emails with the new password.

Then set up a cron job on your web server to run that script automatically every 48 hours.

Thanks :) Nub question but how would I get the script to execute from the cron job? Could I just put the location of where the script is saved in the command box or would be be more complex?

http://i1112.photobucket.com/albums/k485/Lithium_wbb/question.png

Thanks again

bullant
05-27-2011, 07:19 AM
That looks like a screen from your hosting account and is similar but not the same as mine.

You might have to start the path to your script from your domain name. It all depends on how your host has it set up. You will also need to specify the time interval to run the script.

Hopefully your host account has some useful online help guiding you on how to correctly set up cron jobs using that user interface.

kbluhm
05-27-2011, 02:35 PM
What I'd do is set up a cron every hour.

I'd save the date/time of each user's last password change. You then query the database during the cron execution and see if any password changes are over 48 hours ago.

The reason for this?

Let's say the cron runs every 48 hours at 3:00AM. A user signs up at 2:45AM, 15 minutes prior to the cron running. So 15 minutes after signing up, I am already sending that user an email that their password has been changed.

It will also be less emails sent out at a time. Instead of sending out an email to all your users in one go, you're sending them out at varying intervals based on the time of their registration date/time.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum