Author Topic: Accepting duplicate databse entries \ Automatic truncating  (Read 5573 times)

webmaster34

  • Posts: 6
    • View Profile
Accepting duplicate databse entries \ Automatic truncating
« on: June 05, 2004, 04:39:26 am »
Hi

I hope someone can help. I have a custom list that I use for my customised payment process.

Our payment system works as follows. A user enters a received code on our payment page and a username and password are automatically generated and displayed on the next page. On this page I have an optional email function where they can type in their username, password and email address and an email with the info is sent to them.

My problem is this, one user with the same email address might join again after a few days. Once again, he wishes to have his details emailed to him but the database rejects him because he has previously been added. How can I get the database to accept multiple entries or truncate it daily to get rid of the entries for that day.

Thanks in advance
Michael

DW

  • Administrator
  • Posts: 3787
    • View Profile
    • https://legacy.listmailpro.com
Accepting duplicate databse entries \ Automatic truncating
« Reply #1 on: June 07, 2004, 01:31:00 pm »
Try adding the following variable to your ListMail form:

<input type=hidden name=overwrite_dupes value=1>

This will soon be a list option to prevent outside usage.

You will need the v1.77b files from the member area for this to work.
Dean Wiebe
ListMailPRO Author & Developer - Help | Support | Hosting

webmaster34

  • Posts: 6
    • View Profile
Accepting duplicate databse entries \ Automatic truncating
« Reply #2 on: June 09, 2004, 05:10:17 am »
Hi Dean

That worked  :D

Thanks very much, your support is excellent.

Regards
Michael Farah

chufford

  • Posts: 34
    • View Profile
Accepting duplicate databse entries \ Automatic truncating
« Reply #3 on: June 24, 2004, 12:40:13 am »
I needed to allow duplicates also. However, I needed the unique ID (UID) to remain the same for someone who was already subscribed. Here is the modified code I added. It isn't the most efficient, but it looked safe and had minimal risk impact. This change was in signup.php. The first part adds uid to the list of stuff we get from the database.
Code: [Select]
  // check for duplicates
   $cmd = "select id,cnf,uid from $utable where list = '$list' and email like '$email'";
   $result = mysql_query($cmd);
   if(mysql_num_rows($result)>0){
    list($xid,$xcnf,$uid)=mysql_fetch_row($result);

Then, further down, we use the uid if we got one.
Code: [Select]
$uniq = '';
// CH change - If this was a duplicate, I want to use the original UID if possible rather than creating a new one
  if ($uid) {
    $ucmd = "select id from $utable where uid = '$uid'";
    $urow = mysql_query($ucmd);
    $uniq_str = $uid;
    if(@mysql_num_rows($urow)==0) $uniq=1;
  }
// back to original code
 while(!$uniq){
  if($randmaxx) $randmax = $randmaxx;
  $uniq_str = strtolower(substr(md5(rand(0,$randmax)), 0,7));
  $ucmd = "select id from $utable where uid = '$uniq_str'";
  $urow = mysql_query($ucmd);
  if(@mysql_num_rows($urow)==0) $uniq=1;
 }
Chris Hufford