Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    May 2011
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Create random password every 48 hours, email it automatically

    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

  • #2
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    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.

  • Users who have thanked bullant for this post:

    Lithium. (06-05-2011)

  • #3
    New to the CF scene
    Join Date
    May 2011
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by bullant View Post
    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?



    Thanks again

  • #4
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    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.

  • #5
    Senior Coder kbluhm's Avatar
    Join Date
    Apr 2007
    Location
    Philadelphia, PA, USA
    Posts
    1,509
    Thanks
    3
    Thanked 258 Times in 254 Posts
    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.
    Last edited by kbluhm; 05-27-2011 at 02:38 PM.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •