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 5 of 5
  1. #1
    Regular Coder
    Join Date
    May 2005
    Posts
    220
    Thanks
    1
    Thanked 2 Times in 2 Posts

    Submitting Form Data to email?

    I have a friend who said that you can submit data that people input into a form using the mailto function, is this true? I would like to do this without having to use a database.

    Is there a javascript that could do this?...

    Thanks

  • #2
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    Yes, this is certainly possible. The user's input would be sent to an email address you specify, and it would then be up to you to deal with that input.

    Javascript isn't my strongest language, so I won't comment on that, but this could easily be accomplished using the mail() function in php.

    More information on php's mail().

  • #3
    Regular Coder
    Join Date
    May 2005
    Posts
    220
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Can you give me an example of that code? I was hoping to do this by using the html mailto function, not php. Php is a server side language, and I wanted to know if this could be done client side.

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Quote Originally Posted by Vapor View Post
    Can you give me an example of that code? I was hoping to do this by using the html mailto function, not php. Php is a server side language, and I wanted to know if this could be done client side.
    Not reliably. Not everyone has a mail client setup to send email which is why the server side method is preferred. The php mail() function doesn't use a database. As for an example we don't have time to give everyone a simple example. There are many resources out there on the php mail() function. Check out www.hotscripts.com or www.joe2torials.com
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #5
    Senior Coder
    Join Date
    Apr 2007
    Location
    Quakertown PA USA
    Posts
    1,028
    Thanks
    1
    Thanked 125 Times in 123 Posts
    It may well be possible with Javascript - that's just not for me to answer.

    Anyway, here's an example that accepts a user's name and email address and sends it to the address you specify.

    HTML:
    Code:
    <form action="http://yoursite.com/submitform.php" method="post">
    <div>
    Enter name: <input type="text" name="username" size="30" value=""><br />
    Enter email address: <input type="text" name="email" size="30" value=""><br /><br />
    <input type="submit" name="go" value="Submit Data">
    </div>
    </form>
    submitform.php:
    PHP Code:
    <?php
    // get user input
    $username $_POST['username'];
    $useremail $_POST['email'];


    // send email confirmation
    $to  'Me <me@myemail.com>';

    $subject 'User Input Data';

    $message 'Username: ' $username '<br />User Email Address: ' $useremail;

    $headers  "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $headers .= 'From: ' $username ' <' $useremail . >rn";

    mail($to, $subject, $message, $headers);
    ?>
    You would replace the "$to" email information (in the php) with the intended recipient email, and the "form action=" information (in the html) to point to the php file on your site.

    Obviously, this is a very limited example, but you can expand it as needed. I made no effort to format the html, as that would depend on your site.

    HTH

    Edit: _AE_ answered the client-side question.


  •  

    Posting Permissions

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