Pls help me build a script to collect email addresses in a website

Discussion in 'HTML & Website Design' started by wog, Feb 27, 2009.

  1. #1
    Hi..

    I searched the forums.. and the posts i found were of no help,
    I want to create a quick forum, that contains, "Name" / "Email Address".
    And have the info saved in a TXT file on server..

    I have html knowledge.. but none in php..

    Can someone advise if this is possible?


    Thanks.
     
    wog, Feb 27, 2009 IP
  2. salahsoftware.com

    salahsoftware.com Peon

    Messages:
    249
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I am writing the code for you:

    Create a form first:

    <form name="getEmail" action="saveMail.php" method="post">
    Name: <input type="text" name="fullname"><br />
    Email: <input type="text" name="email"><br />
    <input type="submit">
    </form>

    Here is your saveMail.php

    <?php
    $myFile = "maillist.txt";
    $fh = fopen($myFile, 'w') or die("can't open file");
    $stringData = $_GET['fullname'].",".$_GET['email']."\n";
    fwrite($fh, $stringData);
    fwrite($fh, $stringData);
    fclose($fh);
    ?>

    Remember that maillist.text should have chmod 777 if its in linux, for windows there is no need.

     
    salahsoftware.com, Feb 28, 2009 IP
  3. wog

    wog Peon

    Messages:
    161
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Fantastic, I think I am half way there,
    Now,

    The form is created successfuly, and chmod 777 - NP.
    My question:
    How do I upload the files in relation to one another on server, and how do i set the server to save a TXT file in a location that no one has access to?
    I hope I am clear..

    Creating the form in HTML - NP, where to upload the PHP file, how to set the hosting account and where is the TXT file created?

    Thanks for your help!
     
    wog, Feb 28, 2009 IP
  4. American

    American Guest

    Messages:
    46
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4


    To save in a location nobody has access to, use a path before your /public_html/ folder. For example...

    /home/shockhos/logs/file.txt
    (rather than /home/shockhos/public_html/logs/file.txt which would be www.example.com/logs/file.txt)

    Or something similar to that. It depends on how your account it setup and where you actually want to save it.


    You can find out your root path by using this command in PHP...
    echo $_SERVER['DOCUMENT_ROOT'];
    PHP:
     
    American, Feb 28, 2009 IP
  5. ClassHelper.org

    ClassHelper.org Guest

    Messages:
    273
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Another option is to use .htaccess files to control access to the subdirectory you're saving your data files to.
     
    ClassHelper.org, Feb 28, 2009 IP
  6. dinrock

    dinrock Well-Known Member

    Messages:
    1,150
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    128
    #6
    Hi-Hope it's OK to revive this thread. Gotta question about this because I wanna do the same exact thing as WOG. I use FrontPage2002 so am curious if it is acceptable to use that same code SALASOFTWARE just created? Here is my index page: www.danscartoons.com
     
    dinrock, Mar 27, 2009 IP