www.webdeveloper.com
Results 1 to 5 of 5

Thread: form to be sent to an email

  1. #1
    Join Date
    Jul 2009
    Posts
    3

    Question form to be sent to an email

    I want a user to fill out a form and when they click submit, that form gets sent to an email address..
    i've tried action="mailto:blah@blah.com" but that isn't want i'm looking to do. that opens a compose email window.

    I'm wanting it to send the results of the form behind the scenes, and also send that them to a success page when the form is submitted.

    I've also tried using action="mailform.php"

    and here is that code.

    PHP Code:
    <?php

    $to 
    "my@emailaddres.com";
    $subject "TA Online Enrollment Submission";

    while( list( 
    $key$value ) = each$HTTP_POST_VARS ) ) {
        
    $message .= "$key$value\n";
    }

    mail$to$subject$message );

    header"Location: blablahblah.html" );

    ?>
    That is the entire file.

    it sends the user to the success page, but does not send the email.
    Any suggestions?

  2. #2
    Join Date
    Oct 2005
    Posts
    177
    Are you set on using PHP? Why not some simple HTML:

    Code:
    <form name="yourform" action="/cgi-bin/sendmail.pl" method="post">
    <input type="hidden" value="yourname@domain.com" name="recipient">
    <input type="hidden" name="redirect" value="http://www.your.domain/thank_you.html" />
    ....
    </form>
    Of course, you'd need to use the correct path to your server's sendmail script.

    eCat

  3. #3
    Join Date
    Jul 2009
    Posts
    3
    not set on php. didn't think about perl. i'll try it out.

  4. #4
    Join Date
    Jul 2009
    Posts
    3
    This server has cgi - it has sendmail, but it is not a *.pl
    there is a script on the server that the last webmaster put in, but it is very complicated and doesn't work. do you have a simple sendmail script i could use?

  5. #5
    Join Date
    Oct 2007
    Location
    Western Massachusetts, USA
    Posts
    387
    I doubt this is the best solution or even a solution to "behind the scenes", but it is an old method i know of (not many people seem to know of it). Just throwing it out there.
    HTML Code:
    <form method="post" action="mailto:user@domain.tld" enctype="text/plain"> 
    <input type="text" name="username">
    <input type="submit" value="Submit">
    </form>
    The thing to worry about with this old method, is that it will require the user/client to have a way for the broswer to send email. Internet explorer work use the default email client i think. It may not be compatible etc.

    Another method is using POST method to a PHP, ASP, etc script or a CGI script/program. This method could use the sendmail program on a *nix box and send to a given email address. This is the most broswer compatible method, but you may need a lot of validation. There are tons of examples out there.
    Last edited by savvykms; 07-08-2009 at 08:23 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles