Results 1 to 10 of 255

Threaded View

  1. #9
    Join Date
    Apr 2006
    Location
    City Drama in Greece
    Posts
    160
    Plugin Contributions
    6

    Default Unique Serial Number - Pc Configurator

    Dear all,

    I fixed the problem with UNIQUE serial number when a customer creates a new Custom PC.

    As DrByte suggested I made a new DATABASE TABLE :


    CREATE TABLE `serials` (
    `serial_id` int(11) NOT NULL auto_increment,
    `serial_number` varchar(128) NOT NULL default '',
    PRIMARY KEY (`serial_id`)
    ) TYPE=MyISAM AUTO_INCREMENT=1 ;

    Then we use the following code to create a serial number and check if it is UNIQUE.

    If query result = created serial number, then our page reload until the serial number is UNIQUE.


    // If you want to test if this code working just comment $serial_number = md5(uniqid(rand(), true));
    // and uncoment $serial_number = '5' ;
    // Then you will notice that the page where you put this code will be ALLWAYS reloading !!!
    // because serial number "58ffj63g9c6ds56gfd45ghd4ghds56gfsa326" exist on the data base

    // CREATES THE SERIAL NUMBER
    $serial_number = md5(uniqid(rand(), true));

    //$serial_number = '58ffj63g9c6ds56gfd45ghd4ghds56gfsa326' ;

    //CHECK TO SEE IF CREATED SERIAL NUMBER EXISTS ON THE DATABASE
    $check_serial = "SELECT serial_number
    FROM " . TABLE_SERIALS . "
    WHERE serial_number = '" . $serial_number . "'";

    $serial_execute = $db->Execute($check_serial);

    $serial_result = $serial_execute->fields['serial_number'];

    //IF NUMBER EXISTS PAGE RELOAD AND A NEW SERIAL NUMBER IS CREATED
    if($serial_result != "" ) { ?>

    <SCRIPT language=Javascript>

    window.location.reload( true );

    </SCRIPT>

    <?php

    // IF NUMBER DOES NOT EXIST IT IS INSERTED IN DATABASE AS A UNIQUE NUMBER

    }else{

    $productserial = $serial_number;
    //echo $productserial;

    $db->Execute("INSERT INTO " . TABLE_SERIALS . " (serial_number) VALUES ('" . $productserial . "')");

    }
    Many thanks to DrByte for the idea of creatingr a new DATABASE TABLE

    As we talk about RELOADING I would love to share the MATRIX RELOADED swf I use on my website www.lebrand.gr

    Waiting for new suggestions
    Attached Files Attached Files

 

 

Similar Threads

  1. MultiSite Module Support Thread
    By Gerome in forum All Other Contributions/Addons
    Replies: 2239
    Last Post: 21 May 2025, 02:07 PM
  2. v154 WorldPay Module version 3.0 - Support thread
    By countrycharm in forum Addon Payment Modules
    Replies: 115
    Last Post: 20 Jul 2021, 04:00 PM
  3. Form Armor Module Support Thread
    By FormArmor in forum All Other Contributions/Addons
    Replies: 7
    Last Post: 29 Jan 2009, 05:08 AM
  4. Layaway Payment Module Support Thread
    By Danielle in forum Addon Payment Modules
    Replies: 0
    Last Post: 21 Nov 2006, 06:43 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR