Tutorial is here now: http://tutorialzine.com/2010/10/ajaxed-coming-soon-page/

Where it will this:

15          $mysqli->query("INSERT INTO coming_soon_emails
16                          SET email='".$mysqli->real_escape_string($_POST['email'])."'");
17   
18          if($mysqli->affected_rows != 1){
19              throw new Exception('This email already exists in the database.');
20          }

Once it inspections the e-mail isn't a duplicate, I wish it to give a unique (no two email records should have a similar) Alphanumeric code such as this: AQ4ILB9

When the consumer will get the "Thanks!Inch message within the textbox, I would like it to also display the initial code as above.

I must setup a brand new column within the DB for adding a code, correct? What qualities must it have when contributing to perform the above code insertion? Possibly instantly creating the initial code for every record therefore the DB does the random code insertion work as opposed to a loop sign in php?

How do i display the code towards the user when the "Thanks!Inch message is displayed.

Any help editing the tutorial could be much appreciated!

Thanks!

table.sql file

--
-- Table structure for table `coming_soon_emails`
--

CREATE TABLE `coming_soon_emails` (
  `email` varchar(64) collate utf8_unicode_ci NOT NULL,
  `ts` timestamp NOT NULL default CURRENT_TIMESTAMP,
  PRIMARY KEY  (`email`)
) E

ADDITIONAL EDIT
hidden div on coming-soon.php

<div id="code">
Thank you! Your code is: <p style="margin-top:20px;"><?php echo $ref_code;?></p>
</div>

with this I additionally needed to replace

$msg = "Thank you! Subscription Code: " . $email_code;

with

$ref_code = "example.com/" . $email_code;

If you browse the script.js file, mine continues to be modified to:

$(document).ready(function(){

    // Binding event listeners for the form on document ready

    $('#email').defaultText('Your Email Address');

    // 'working' prevents multiple submissions
    var working = false;

    $('#form').submit(function(){

        if(working){
            return false;
        }
        working = true;

        $.post("./index.php",{email:$('#email').val()},function(r){
            if(r.error){
                $('#email').val(r.error);
            }
            else { $("#form").hide(); $("#code").fadeIn('slow');}

            working = false;
        },'json');

        return false;
    });
});

// A custom jQuery method for placeholder text:

$.fn.defaultText = function(value){

    var element = this.eq(0);
    element.data('defaultText',value);

    element.focus(function(){
        if(element.val() == value){
            element.val('').removeClass('defaultText');
        }
    }).blur(function(){
        if(element.val() == '' || element.val() == value){
            element.addClass('defaultText').val(value);
        }
    });

    return element.blur();
}

However, the else { $("#form").hide(); $("#invite").fadeIn('slow');} is no more working! Ideas?