How can I save or log the email addresses in this form?

Discussion in 'PHP' started by sellerscentral, Nov 7, 2011.

  1. #1
    Here's the form I am using. When a user input the email address in the form below ...how do I change it so that the email address is saved in a file or mailed to me?

    <form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>" method="post">
    <input type="text" name="email" value="<?php echo htmlspecialchars($email); ?>"><br>
    <input type="submit">
     
    </form>
    Code (markup):

     
    sellerscentral, Nov 7, 2011 IP
  2. dixcoder

    dixcoder Member

    Messages:
    71
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    26
    #2
    <form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>" method="post">
    <input type="text" name="email" value="<?php echo htmlspecialchars($email); ?>"><br>
    <input type="submit" name="submit">

    </form>

    <?php
    if(isset($_REQUEST['submit']))
    {
    $to = $_REQUEST['email'];
    $subject = 'the subject';
    $message = 'hello';
    $headers = 'From: ' . "\r\n" .
    'Reply-To: ' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

    mail($to, $subject, $message, $headers);
    }
    ?>

    this is the sample script
     
    dixcoder, Nov 7, 2011 IP