gum1982 Posted November 18, 2009 Share Posted November 18, 2009 Hi all I have setup my script through paypal ipn so that after the payment has been processed it sends a unique url to the customers email. This is the script if the payment is Verified!! $email = $_POST['payer_email']; $url = "http://www.example.com/survey.php?formid=" . urlencode($formid); $to = $email; $str = "Survey".date('M Y', time()); $html_data = '<html> <head> <title> Survey </title> </head> <body bgcolor="#fff0ff" text="#0000ee"> Thank you for your purchase Your account information Email: '.$email.' Direct Link to Survey: <a href='.$url.'>Link To Survey.</a> </body></html>'; $mime = new MIME_mail("Survey", $to, $str); $mime->attach($html_data, "", HTML, BASE64); $mime->send_mail(); } Ok so this works fine and sends the link with the url to the survey. But the client has said that he wants the link to become unusable after 28 days is this possible and where would i set the script up for this. Any Help Please People?? Quote Link to comment https://forums.phpfreaks.com/topic/181988-28-day-session/ Share on other sites More sharing options...
play_ Posted November 18, 2009 Share Posted November 18, 2009 You could try storing the link in the database, which stores the URL and a timestamp. whenever the script is executed, query the database based on 'formid'. then compare timestamps. Quote Link to comment https://forums.phpfreaks.com/topic/181988-28-day-session/#findComment-959896 Share on other sites More sharing options...
gum1982 Posted November 18, 2009 Author Share Posted November 18, 2009 Ok thanks for the reply i am in the process off trying to set this up ill let you know how i get on. Quote Link to comment https://forums.phpfreaks.com/topic/181988-28-day-session/#findComment-959910 Share on other sites More sharing options...
gum1982 Posted November 18, 2009 Author Share Posted November 18, 2009 ok so i have set a field in the database that stores the unique url and the time it was created, so if i run a loop on the database this is what it returns. http://www.example.com/survey.php?formid=1258561238-21611319133 2009-11-18 16:20:34 http://www.example.com/survey.php?formid=1258561141-21611319133 2009-11-18 16:18:57 http://www.example.com/survey.php?formid=1258560211-21611319133 2009-11-18 16:03:27 Do i need to setup a cronjob to query the the database. So when date.id = + 28 days it makes the link void. Is this the right process or am i miles out. Also how would i effect the link in their email as i am only altering the link in the database?? Quote Link to comment https://forums.phpfreaks.com/topic/181988-28-day-session/#findComment-960073 Share on other sites More sharing options...
DavidAM Posted November 18, 2009 Share Posted November 18, 2009 1) Just store the unique formid, and make it a key on the table 2) When the user clicks the link and lands on your page, lookup the formid ($_GET['formid']) in the database and retrieve the creation date 3) If the current date is more than 28 days (or whatever) display a message saying the survey has expired (or whatever). 4) If the formid does not exist in the database, display a message saying it has expired or was entered incorrectly. You will probably want a cron job to delete old entries. That all depends on how much space you have and how many links are generated and what data is important to you. Or you might want to track whether the user responded to the link and maybe when so you can determine if 28 days is too much or too little or just right. EDIT: Forgot to mention: I do not think there is any way to affect the email in the user's mailbox. They are going to be stuck with an expired formid or a stale link. That's why I suggested #4 above, atleast if they click it next month, they get your website. Quote Link to comment https://forums.phpfreaks.com/topic/181988-28-day-session/#findComment-960216 Share on other sites More sharing options...
gum1982 Posted November 18, 2009 Author Share Posted November 18, 2009 Brilliant this is great information thanks, i will try and report back. Quote Link to comment https://forums.phpfreaks.com/topic/181988-28-day-session/#findComment-960221 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.