Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Wanting to start a mailing list

    Hey everyone ,

    I am really interested in putting a mailing list on my website. I have only just discovered php and mysql and I found a program called php list on my cPanel X control panel on my website.

    I would like to put a text box on my navigation bar that has inside it "enter your e-mail" (when they click this disappears) and a button on the right of that which says "join" (I will have a jpg underneath this text box saying "Mailing List").

    When someone clicks on "join" I would like them to get sent to a page with the e-mail address field filled out in the right table with what the address they entered in the navigation pane, along with a name field they can fill out and a Submit button.

    I have seen these on many websites so I assume it is not that hard to do, but I am pretty lost as to how everything is connected (the database (mysql?) and the php list program).

    I assume when they click submit it will send their details to a mysql database / send them a confirmation e-mail.

    I was wondering what code I will need to make this system work, as I have been reading and googling and I am quite lost as to the mechanics of how it all works

    Any help is appreciated!

    Thanks,
    - Sepp.

  • #2
    Regular Coder mic2100's Avatar
    Join Date
    Feb 2006
    Location
    Scunthorpe
    Posts
    562
    Thanks
    15
    Thanked 28 Times in 27 Posts
    hi,

    you will need to use javascript to make the text in the box disapear when you click it, and PHP for loading the email addresses into the DB.

    javascript: (use this in the textbox)
    Code:
    onclick="if( this.value =='Enter keyword'){this.value=' '}"
    Full Example:
    PHP Code:

    <?

    if(isset($_POST['emailAddress']) and $_POST['emailAddress'] != 'Enter Email Address')
    {

        
    $hostname_conn_email "server Address";
        
    $database_conn_email "database";
        
    $username_conn_email "username";
        
    $password_conn_email "password";
        
        
    $conn_email mysql_pconnect($hostname_conn_email$username_conn_email$password_conn_email) or trigger_error(mysql_error(),E_USER_ERROR);
        
        
    mysql_select_db($database_comm_email$conn_email);

        
    $insertSQL "INSERT INTO databaseName (fieldname) VALUES ('".addslashes($_POST['emailAddress'])."')";
        
        
    $result1 mysql_query($insertSQL$conn_email) or die(mysql_error());

    }

    ?>
    <form id="form1" name="form1" method="post" action="<?=$_SERVER['PHP_SELF']?>">
      <input name="emailAddress" type="text" id="emailAddress" value="Enter Email Address" onclick="if( this.value =='Enter Email Address'){this.value=' '}" />
      <input type="submit" name="Submit" value="Join!" />
    </form>
    I havn't checked this but i am sure that i will work but may need tweeking a bit.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •