Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14

Thread: E-Mail Form?

  1. #1
    Senior Member amcdeathknight's Avatar
    Join Date
    Oct 2004
    Location
    New Zealand
    Posts
    150
    Member #
    7776
    Hey, I wish to put an email form on m the contact page of my site, how am i to do that? Thanks

  2.  

  3. #2
    Member drewrockshard's Avatar
    Join Date
    Feb 2004
    Location
    Garland (Dallas), Texas
    Posts
    45
    Member #
    4946
    Quote Originally Posted by amcdeathknight
    Hey, I wish to put an email form on m the contact page of my site, how am i to do that? Thanks
    if you have php enabled, program it using that. with xhtml and css (css optional)

    all you do is create the form and parse the form via php variables and using the mail() function.

    I wrote a small php program that does this, very nicely. if can send HTML formatted emails and has a built in "ip retriever" and a few other things. if you are interested (free of charge), id be willing to get it to you and show you how to alter it and such.

    good luck and let me know what i can do for ya. my email can be found in my profile.
    Thanks,
    Drew

  4. #3
    Senior Member justlivyalife's Avatar
    Join Date
    Jul 2003
    Location
    Birmingham, UK
    Posts
    2,871
    Member #
    2374
    It would be useful to the WDF community if you could post the code here? Only if you wish of course. Many Thanks.
    justlivyalife - The future depends on what we do in the present. (Mahatma Gandhi)
    WDF Resources: WDF Rules
    Non-WDF: JavascriptSource | Dynamic Drive | phpBB | HTML-Kit | Winamp | Download Firefox | Morguefile

  5. #4
    Junior Member
    Join Date
    Oct 2004
    Posts
    10
    Member #
    7768
    Another alternative is using Perl. First, use something like this to build your form and name the page anything you want:
    Code:
    <html><head><title>
    Send Me An Email
    </title></head>
    
    <body>
    
    <form action="/cgi-bin/sendemail" method="post">
    <table>
    <tr><td colspan="2">Send me email</td></tr>
    <tr><td align="right">From: </td>
        <td><input type="text" name="from">[if you want me to reply, enter your address]</td></tr>
    <tr><td align="right">Subject: </td>
        <td><input type="text" name="subject"></td></tr>
    <tr><td align="right" valign="top">Message: </td>
        <td><textarea name="body" cols="50" rows="15"></textarea></td></tr>
    <tr><td>&nbsp;</td>
        <td><input type="submit" value="Send"></td></tr>
    </table>
    </form>
    
    </body>
    </html>
    Next, use this code for your Perl script:
    Code:
    #!/usr/bin/perl
    use strict;
    
    # change these two lines
    my $sendto = "email\@address.com";
    my $sendmail = "/usr/sbin/sendmail -t -n -oi";
    
    sub sendit
            {
            my ($from, $to, $subject, $body) = (@_);
            open(MAIL, "| $sendmail") or die "Content-type: text/html\n\nError code: 61";
    
    print MAIL <<EOF;
    From: $from
    Reply-to: $from
    Errors-to: $from
    Sender: $from
    To: $to
    Subject: $subject
    
    $body
    
    EOF
    
    close(MAIL);
            } # end sub sendit
    
    my %vars = ();
    my $info = "";
    
    if($ENV{"REQUEST_METHOD"} eq 'GET')
            { $info = $ENV{"QUERY_STRING"}; }
          else
            { read(STDIN, $info, $ENV{"CONTENT_LENGTH"}) }
    
    $info =~ s/\+/ /g;
    my @infolist = split(/&/, $info);
    
    foreach my $item (@infolist)
            {
            my ($key, $value) = split(/=/, $item);
            $value =~ s/%([A-Fa-f0-9]{2})/pack("c",hex($1))/ge;
            $vars{$key} = $value;
            $vars{$key} =~ s/</\&lt;/gi;
            }
    
    &sendit(lc($vars{from}), lc($sendto), $vars{subject}, $vars{body});
    my $time = localtime();
    
    print <<HTML;
    content-type: text/html
    
    Email sent at $time.<br>
    HTML
    Name this file sendemail, dump it into your cgi-bin in ASCII mode and chmod it to 755. You'll need to make sure the very first line of the perl code reflects where your host says the perl interpreter is located. You also need to change the two noted lines to your email address and the location of sendmail on your host. At the very end of the perl code, between the print <<HTML; and HTML lines, you can put custom HTML code so the script response matches the look of your site.

    If anyone seriously wants to try this method, feel free to send me a private message on here and I'll try and walk you through it.

  6. #5
    Senior Member
    Join Date
    Mar 2004
    Posts
    1,518
    Member #
    5220
    Perl is often more complicated than PHP though I find. Check out the PHP/MySQL forum - there is loads of posts (mostly from me ) about this subject.
    Rednerve
    Creative Freelance Design

  7. #6
    Senior Member amcdeathknight's Avatar
    Join Date
    Oct 2004
    Location
    New Zealand
    Posts
    150
    Member #
    7776
    oh i do not and can not have php enabled, is there a html way of doing it?

  8. #7
    Senior Member Brak's Avatar
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    3,413
    Member #
    1217
    Liked
    2 times
    Yep, although it completely voids the point of having an email form anyway.

    The shortcut is in the form tag go: <form action="mailto:youremail@yourdomain.com" method="POST"> That'll send it to your email more or less. It will be a mess though, be forwarned. You should at least have Perl/CGI enabled... check with your host.
    Kyle Neath: Rockstar extraordinare
    The blog | The poetry site | The Spore site

  9. #8
    Senior Member
    Join Date
    Mar 2004
    Posts
    1,518
    Member #
    5220
    Exactly. The mailto just sucks. It will make the mail function unusable for the majority of your visitors and it's just well....ugly!
    Rednerve
    Creative Freelance Design

  10. #9
    Member drewrockshard's Avatar
    Join Date
    Feb 2004
    Location
    Garland (Dallas), Texas
    Posts
    45
    Member #
    4946
    wow...no php enabled and you wanna do it the HTML way?

    thats not a great idea, as stated by the many users above. i just got home, and yes, you really should not have an HTML way of doing the forms. also as stated above, use the perl way since php isnt enabled (unless perl isnt enabled either).

    if you only have html to work with, im really sorry, but when it comes to mail forms, its best for it to be programmed instead of "marked up".

    best of luck to you.
    Thanks,
    Drew

  11. #10
    Senior Member amcdeathknight's Avatar
    Join Date
    Oct 2004
    Location
    New Zealand
    Posts
    150
    Member #
    7776
    hey its fine, I have something called cgi enabled, would that help?


Page 1 of 2 1 2 LastLast

Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 07:40 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com