Jump to content

Recommended Posts

 

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??

 

Link to comment
https://forums.phpfreaks.com/topic/181988-28-day-session/
Share on other sites

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??

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/181988-28-day-session/#findComment-960073
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/181988-28-day-session/#findComment-960216
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.