WEB Can someone advise on how to write a good email capture form?

Discussion in 'OT Technology' started by shaitaan, Aug 11, 2009.

  1. shaitaan

    shaitaan New Member

    Joined:
    Jul 12, 2002
    Messages:
    49,620
    Likes Received:
    0
    Location:
    Bay Area, CA / NYC
    I'm noobish with php / mysql, and outside of the basics (store email, etc), I'm lost :o

    as of now, what I have is at: http://www.netstudio.com/temp/

    stores the email in the db, but has no validation. How do I write rules that accomplish the following?

    1.) If someone doesn't enter in an email, or types in gibberish it still pops a new page with the download link, but does not store a blank line/ gibberish line in the db



    :hsd: I'm trying to collect email addresses now, to begin email marketing techniques to recover possible lost sales. I'm such a noob :(


    any advice would be much appreciated :wavey:
     
  2. shaitaan

    shaitaan New Member

    Joined:
    Jul 12, 2002
    Messages:
    49,620
    Likes Received:
    0
    Location:
    Bay Area, CA / NYC
    oh yeah, current code:

    form
    Code:
    
    <?php
    
    require_once 'dbconnect.php';
    
    if(isset($_POST['save'])){
    
    $email = addslashes($_POST['email']);
    
    mysql_query("insert into users values ('','$email')") or die(mysql_error());
    
    /* Display thank you message and exit */
    
    echo '
    
    <h1>Thank You For Downloading!</h1><br>
    
    ';
    
    exit;
    
    }
    
    /* Else display the form so the user can register */
    
    echo '
    
    <form method="post">
    
    Email: <br/><input type="text" name="email"/><br/><br/>
    
    <input type="image" src="/images/download-12.gif" name="save" value="Register" onmouseover="javascript:this.src="/images/download-12-green.gif"; onmouseout="javascript:this.src="/images/download12.gif";/>
    
    </form>
    
    ';
    
    /* Close MySQL, exit and close PHP */
    
    mysql_close();
    
    exit;
    
    ?>
    



    dbconnect.php
    Code:
    <?php
    
    $dbname = 'db01';
    
    $hostname = 'localhost';
    
    $dbuser = 'XXXXXXX';
    
    $dbpass = '*******';
    
    $connect = mysql_connect($hostname,$dbuser,$dbpass) or die('Could not connect to MySQL please insure that the connection information is correct');
    
    mysql_select_db($dbname,$connect) or die('Could not select the database');
    
    ?>
     
  3. shaitaan

    shaitaan New Member

    Joined:
    Jul 12, 2002
    Messages:
    49,620
    Likes Received:
    0
    Location:
    Bay Area, CA / NYC

    you lost me at "you"

    :o
     

Share This Page