42 users online (0 members and 42 guests)  


  Results 1 to 14 of 14

Related

  1. Help with forms    Forum: HTML Forum
    Replies: 6
  2. Forms    Forum: HTML Forum
    Replies: 11
  3. Forms    Forum: HTML Forum
    Replies: 6
  4. Help with forms please....    Forum: HTML Forum
    Replies: 1
  1. #1
    jeffg1's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2002
    Posts
    7

    Cool Question on forms

    Hello friends,

    Had a question about html forms. I'm using the formmail.pl script and everything works fine, except for one thing. When I receive the form results in my email the Subject looks good but the "From" box has the email address of the host instead of the users email that submitted it. How can I capture the inputed email address and have it show up in the "From" field in my email box? It would nice to be able to hit the "Reply" button when returning emails and have the users email address show up instead of the host company.

    Is there a hidden input element that does this?

    Appreciate any advice! Thanks,

    Jeff

  2. #2
    Derek's Avatar
    Be Yourself

    Status
    Offline
    Join Date
    Aug 2001
    Location
    St. George, Utah, USA
    Posts
    466
    I'm nothin to speak of at perl but I have seen a script or two...

    wanna post some code?

  3. #3
    jeffg1's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2002
    Posts
    7

    Here is the html that I am using

    Hey Derek!

    Thanks for your response. Here is the form code that I am using for a contest entry.

    <form method="post" action="http://www.maplestreetmusic.com/cgi-bin/FormMail.pl">
    <p><font size="-1" face="Verdana, Arial, Helvetica, sans-serif" color="#000066">
    Name:
    <input type="text" name="Name" value="" size="12" maxlength="100">
    <br>
    Email:
    <input type="text" name="Email" value="" size="12" maxlength="100"></font><br></p>
    <input type="hidden" name="subject" value="April 2002 CD Giveaway!">
    <input type="hidden" name="redirect" value="http://www.maplestreetmusic.com/thankyou1.htm">
    <input type="hidden" name="recipient" value="contest@maplestreetmusic.com">
    <input type="submit" value="Submit" name="submit">
    <input type="reset" value="Reset" name="reset">
    </form>


    Any way to grab that email variable and have it end up in the "From" field in the results email that FormMail sends you?

    Thanks,

    Jeff

  4. #4
    Derek's Avatar
    Be Yourself

    Status
    Offline
    Join Date
    Aug 2001
    Location
    St. George, Utah, USA
    Posts
    466
    what is your FormMail.pl code?

  5. #5
    jeffg1's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2002
    Posts
    7

    Follow-up

    Maybe this is something that can be configured in the perl code, I'm starting to think it has nothing to do with the html and form... outside of maybe using the element name to reference in the formmail.pl program. Hum!

    I'm guessing. Any thoughts. Thanks!

    Jeff

  6. #6
    jeffg1's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2002
    Posts
    7
    Derek,

    The perl code is too long to fit into the reply box. Any suggestions?

    Thanks!

  7. #7
    Derek's Avatar
    Be Yourself

    Status
    Offline
    Join Date
    Aug 2001
    Location
    St. George, Utah, USA
    Posts
    466
    Ya, it does have to do with the Perl code, but if the perl code doesn'et have the "reply-to" thing then I don't think I have the knowledge yet to make one up for lol... sorry. If know one can help you here try devshed...

  8. #8
    jeffg1's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2002
    Posts
    7
    This looks like the section of perl that might deal with this issue: Tell me what you think. Thanks!



    # Otherwise, begin printing the response page. #
    else {

    # Print HTTP header and opening HTML tags. #
    print "Content-type: text/html\n\n";
    print "<html>\n <head>\n";

    # Print out title of page #
    if ($Config{'title'}) { print " <title>$Config{'title'}</title>\n" }
    else { print " <title>Thank You</title>\n" }

    print " </head>\n <body";

    # Get Body Tag Attributes #
    &body_attributes;

    # Close Body Tag #
    print ">\n <center>\n";

    # Print custom or generic title. #
    if ($Config{'title'}) { print " <h1>$Config{'title'}</h1>\n" }
    else { print " <h1>Thank You For Filling Out This Form</h1>\n" }

    print "</center>\n";

    print "Below is what you submitted to $Config{'recipient'} on ";
    print "$date<p><hr size=1 width=75\%><p>\n";

    # Sort alphabetically if specified: #
    if ($Config{'sort'} eq 'alphabetic') {
    foreach $field (sort keys %Form) {

    # If the field has a value or the print blank fields option #
    # is turned on, print out the form field and value. #
    if ($Config{'print_blank_fields'} || $Form{$field}) {
    print "<b>$field:</b> $Form{$field}<p>\n";
    }
    }
    }

    # If a sort order is specified, sort the form fields based on that. #
    elsif ($Config{'sort'} =~ /^order:.*,.*/) {

    # Set the temporary $sort_order variable to the sorting order, #
    # remove extraneous line breaks and spaces, remove the order: #
    # directive and split the sort fields into an array. #
    $sort_order = $Config{'sort'};
    $sort_order =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
    $sort_order =~ s/(\s+)?\n+(\s+)?//g;
    $sort_order =~ s/order://;
    @sorted_fields = split(/,/, $sort_order);

    # For each sorted field, if it has a value or the print blank #
    # fields option is turned on print the form field and value. #
    foreach $sorted_field (@sorted_fields) {
    if ($Config{'print_blank_fields'} || $Form{$sorted_field}) {
    print "<b>$sorted_field:</b> $Form{$sorted_field}<p>\n";
    }
    }
    }

    # Otherwise, default to the order in which the fields were sent. #
    else {

    # For each form field, if it has a value or the print blank #
    # fields option is turned on print the form field and value. #
    foreach $field (@Field_Order) {
    if ($Config{'print_blank_fields'} || $Form{$field}) {
    print "<b>$field:</b> $Form{$field}<p>\n";
    }
    }
    }

    print "<p><hr size=1 width=75%><p>\n";

    # Check for a Return Link and print one if found. #
    if ($Config{'return_link_url'} && $Config{'return_link_title'}) {
    print "<ul>\n";
    print "<li><a href=\"$Config{'return_link_url'}\">$Config{'return_link_title'}</a>\n";
    print "</ul>\n";
    }

    # Print the page footer. #
    print <<"(END HTML FOOTER)";
    <hr size=1 width=75%><p>
    <p align="center"><br><font face="Arial" size="1">Powered By <a href="http://www.webmasters.com" target="_blank">WEBMASTERS.COM</a></font></p>
    </body>
    </html>
    (END HTML FOOTER)
    }
    }

    sub send_mail {
    # Localize variables used in this subroutine. #
    local($print_config,$key,$sort_order,$sorted_field,$env_report);

    # Open The Mail Program
    open(MAIL,"|$mailprog -t");

    print MAIL "To: $Config{'recipient'}\n";
    print MAIL "From: $Config{'email'} ($Config{'realname'})\n";

    # Check for Message Subject
    if ($Config{'subject'}) { print MAIL "Subject: $Config{'subject'}\n\n" }
    else { print MAIL "Subject: WWW Form Submission\n\n" }

    print MAIL "Below is the result of your feedback form. It was submitted through $url by\n";
    print MAIL "$Config{'realname'} ($Config{'email'}) on $date\n";
    print MAIL "-" x 75 . "\n\n";

    if (@Print_Config) {
    foreach $print_config (@Print_Config) {
    if ($Config{$print_config}) {
    print MAIL "$print_config: $Config{$print_config}\n\n";
    }
    }
    }

    # Sort alphabetically if specified: #
    if ($Config{'sort'} eq 'alphabetic') {
    foreach $field (sort keys %Form) {

    # If the field has a value or the print blank fields option #
    # is turned on, print out the form field and value. #
    if ($Config{'print_blank_fields'} || $Form{$field} ||
    $Form{$field} eq '0') {
    print MAIL "$field: $Form{$field}\n\n";
    }
    }
    }

    # If a sort order is specified, sort the form fields based on that. #
    elsif ($Config{'sort'} =~ /^order:.*,.*/) {

    # Remove extraneous line breaks and spaces, remove the order: #
    # directive and split the sort fields into an array. #
    $Config{'sort'} =~ s/(\s+|\n)?,(\s+|\n)?/,/g;
    $Config{'sort'} =~ s/(\s+)?\n+(\s+)?//g;
    $Config{'sort'} =~ s/order://;
    @sorted_fields = split(/,/, $Config{'sort'});

    # For each sorted field, if it has a value or the print blank #
    # fields option is turned on print the form field and value. #
    foreach $sorted_field (@sorted_fields) {
    if ($Config{'print_blank_fields'} || $Form{$sorted_field} ||
    $Form{$sorted_field} eq '0') {
    print MAIL "$sorted_field: $Form{$sorted_field}\n\n";
    }
    }
    }

    # Otherwise, default to the order in which the fields were sent. #
    else {

    # For each form field, if it has a value or the print blank #
    # fields option is turned on print the form field and value. #
    foreach $field (@Field_Order) {
    if ($Config{'print_blank_fields'} || $Form{$field} ||
    $Form{$field} eq '0') {
    print MAIL "$field: $Form{$field}\n\n";
    }
    }
    }

    print MAIL "-" x 75 . "\n\n";

    # Send any specified Environment Variables to recipient. #
    foreach $env_report (@Env_Report) {
    if ($ENV{$env_report}) {
    print MAIL "$env_report: $ENV{$env_report}\n";
    }
    }

    close (MAIL);
    }

    sub check_email {
    # Initialize local email variable with input to subroutine. #
    $email = $_[0];

    # If the e-mail address contains: #
    if ($email =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||

    # the e-mail address contains an invalid syntax. Or, if the #
    # syntax does not match the following regular expression pattern #
    # it fails basic syntax verification. #

    $email !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/) {

    # Basic syntax requires: one or more characters before the @ sign, #
    # followed by an optional '[', then any number of letters, numbers, #
    # dashes or periods (valid domain/IP characters) ending in a period #
    # and then 2 or 3 letters (for domain suffixes) or 1 to 3 numbers #
    # (for IP addresses). An ending bracket is also allowed as it is #
    # valid syntax to have an email address like: user@[255.255.255.0] #

    # Return a false value, since the e-mail address did not pass valid #
    # syntax. #
    return 0;
    }

    else {

    # Return a true value, e-mail verification passed. #
    return 1;
    }
    }

    sub body_attributes {
    # Check for Background Color
    if ($Config{'bgcolor'}) { print " bgcolor=\"$Config{'bgcolor'}\"" }

    # Check for Background Image
    if ($Config{'background'}) { print " background=\"$Config{'background'}\"" }

    # Check for Link Color
    if ($Config{'link_color'}) { print " link=\"$Config{'link_color'}\"" }

    # Check for Visited Link Color
    if ($Config{'vlink_color'}) { print " vlink=\"$Config{'vlink_color'}\"" }

    # Check for Active Link Color
    if ($Config{'alink_color'}) { print " alink=\"$Config{'alink_color'}\"" }

    # Check for Body Text Color
    if ($Config{'text_color'}) { print " text=\"$Config{'text_color'}\"" }
    }

    sub error {
    # Localize variables and assign subroutine input. #
    local($error,@error_fields) = @_;
    local($host,$missing_field,$missing_field_list);

    if ($error eq 'bad_referer') {
    $host = $url;
    print <<"(END ERROR HTML)";
    Content-type: text/html

    <html>
    <head>
    <title>Bad Referrer - Access Denied</title>
    </head>
    <body link="#0000ff" vlink="#0000ff">
    <center>
    <table border=0 width=600 bgcolor=#9C9C9C>
    <tr><th><font size=+2>Bad Referrer - Access Denied

  9. #9
    Derek's Avatar
    Be Yourself

    Status
    Offline
    Join Date
    Aug 2001
    Location
    St. George, Utah, USA
    Posts
    466
    well I think I've seen that code somewhere on a mail script (I just looked it up to see if I can find out how, but no good)... BUT... PHP is something that I do know, so if you have it enabled...

    strip_tags($name);
    strip_tags($subject);
    strip_tags($email);
    strip_tags($message);
    mail("dave@colorconceptsdesign.com", "$subject", "
    Name: $name\n
    Message: $message\n", "From: Color Concepts Contact Form\nReply-to: $email\n");

    echo "
    Thank You For Your Submission, You May Now Return To Viewing The Rest Of Our Site.<br> -Dave & Steve-";
    if your wondering where I got the $name, $subject, etc. from, it came from the input names...

    "Name: <input type="text" name="name"><br>
    Subject: <input type="text" name="subject"><br>
    "...

    but otherwise I can't help ya with your perl script.

  10. #10
    jeffg1's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2002
    Posts
    7
    Thanks for all your help. Sorry for the delay, took a nap!

    I don't know anything about PHP, the script you typed in, would that be embedded into the web page or call it as an external file like the formmail script?

  11. #11
    Enigma's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Nov 2000
    Posts
    426
    It may be that the problem is that the form and the script are using different variable names.

    In the form, the variable names for the email address and the name are Email and Name, while in the script, it looks like the variable names are email and realname. Try changing the form variables to match the script variables.

  12. #12
    jeffg1's Avatar
    New User

    Status
    Offline
    Join Date
    Apr 2002
    Posts
    7

    You rock!!

    Enigma,

    Thanks for your help! It was that simple. That did exactly what I needed it to do.

    Derek, you da man too... appreciate your help as well.

    See ya around! Take care,

    Jeff

  13. #13
    Enigma's Avatar
    Senior Member

    Status
    Offline
    Join Date
    Nov 2000
    Posts
    426
    You're welcome!

    I've gone cross-eyed many a late night, looking for things like that! Good thing that it hasn't warped me too bad!
    Last edited by HTML; 03-08-2012 at 11:37 AM.

  14. #14
    Derek's Avatar
    Be Yourself

    Status
    Offline
    Join Date
    Aug 2001
    Location
    St. George, Utah, USA
    Posts
    466
    hey... thanks for pointing that out lol guess I was scanning the 'code' and not the 'names' hehe, and since I write everything myself my problems are usually my code



Tags for this Thread