1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 1999
    St.JOhn's, Newfoundland, Canada
    Rep Power
    I am looking for some one to give me a simple script that will allow a user to enter their email address and have it stored in a mysql database.

    the table name is Email just show me where to put the other info.

    Thanks in Advance
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Chicago IL, USA
    Rep Power
    create a file named test.php3 with the everything between the ==== (don't include the ====) below in the file. You may have to fine tune the html form a bit.

    Note the hidden "action" field. When the form is submitted (via POST) the field $action is available. Pass that to the addEmailToDb function and do an insert into the db.

    If the $action field has no value (i.e., you just open the file in the browser) then it will execute the showForm() function, which will draw the form instead of inserting into the db.

    function addEmailToDb($email_addr){
    $HOSTNAME = "your_host";
    $DB_LOGIN = "your_db_user";
    $DB_PASSWD = "your_password";
    $DB_NAME = "your_db_name";
    $db = mysql_connect($HOSTNAME, $DB_LOGIN, $DB_PASSWD);

    $sql = "Insert INTO email values('$email_addr')";
    $result = mysql_query($sql);
    if (! $result) {
    echo "an error occurred. email was not inserted into the db.";
    } else {
    echo "email was successfully inserted into the db.";


    function showForm() {
    echo "<html>n";
    echo "<head>n";
    echo "<title>Add Email</title>n";
    echo "</head>n";
    echo "<body bgcolor='#FFFFFF'>n";
    echo "<table width=100% height=75%><tr><td><center>n";
    echo "<table cellpadding=2><tr><td bgcolor=#b2b4f6><center>n";
    echo "<table cellpadding=20><tr><td bgcolor=#ffffff><center>n";
    echo "<form action='$PHP_SELF'>n";
    echo "<input type=hidden name=action value=add_email>n";
    echo "<table cellpadding=5 cellspacing=1>n";
    echo "<tr><td>Password </td><td> <input type=password name=email_addr></td></tr>n";
    echo "</table><p>n";
    echo "<input type=submit value='Enter' default>n";
    echo "<input type=reset value='Clear'><br>n";
    echo "</form>n";
    echo "</center></td></tr></table>n";
    echo "</center></td></tr></table>n";
    echo "</center></td></tr></table>n";
    echo "</body>n";
    echo "</html>n";

    if ( $action == "admin") {
    } else ( $action == "") {


    Hope this helps.


Similar Threads

  1. php script won't work inside "cgi-local" directory
    By Volitics in forum PHP Development
    Replies: 5
    Last Post: April 26th, 2004, 10:50 PM
  2. Replies: 9
    Last Post: February 26th, 2004, 04:55 PM
  3. Perl script converting GIF and JPG images to BMP ???
    By Deanna475 in forum Perl Programming
    Replies: 20
    Last Post: February 17th, 2004, 06:35 PM
  4. Replies: 2
    Last Post: February 10th, 2004, 11:03 PM
  5. How can I enable a power user to run this script?
    By Yamadatroy in forum Visual Basic Programming
    Replies: 2
    Last Post: January 19th, 2004, 09:39 PM

IMN logo majestic logo threadwatch logo seochat tools logo