WordPress.org

Ready to get started?Download WordPress

Forums

Simple "Enter email" form? (2 posts)

  1. colorrush
    Member
    Posted 2 years ago #

    Hi!

    I am currently working on a site, and I am using the plugin Maintenance Mode 5.4 so people can't see the site while I'm working on it and it's all messy :)

    I then want a funktion on the "maintenance mode" site you land on, where people can enter their email adress so that I can notify them once the site is up and running.

    I'm looking for a simple solution where the email adresse is typed in a form/box and then stored somewhere (maybe in the plugin itself) so that i'll have a list of emails when the site is complete.

    Anyone who knows of such a plugin or can help in another way?

    I would be very thankful!

  2. Christian
    Member
    Posted 2 years ago #

    Maybe the simplest possible way without a database or plugings:

    <form action="http://yourwordpressaddress.com/mail.php" method="post">
    Give your email address if you want to something... <input type="text" name="email">
    <input type="submit" value="Submit!">
    </form>

    And the mail.php file you must store to wordpress root directory:

    <?php
    $to = "youremail@serviceprovider.com";
    $subject = "Email from My Site";
    $message =
    $_POST['email'];
    $headers = "From:" . $from;
    mail($to,$subject,$message,$headers);
    ?>

    This would send an one line email to your email address. Or you could store it in your database, even in the same where wordpress is located.
    To store it in a mySQL database:

    <?php
    $con = mysql_connect("localhost","username,"password");
    if (!$con)
      {
      die('Could not connect: ' . mysql_error());
      }
    
    mysql_select_db("THEDATABASEYOUWANT", $con);
    
    $sql="INSERT INTO Tablecontainingtheaddresses (Email)
    VALUES
    ('$_POST[firstname]')";
    
    if (!mysql_query($sql,$con))
      {
      die('Error: ' . mysql_error());
      }
    echo "Email added";
    
    mysql_close($con);
    ?>

    You must create a new table in your database though.

Topic Closed

This topic has been closed to new replies.

About this Topic