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 16
  1. #1
    Senior Member Tech0rz's Avatar
    Join Date
    Aug 2004
    Location
    Northwest, Eng
    Posts
    128
    Member #
    7314
    The site:
    The Requirement: On the contact page, under the e-mail section, I want a simple form using Name, E-Mail address and question/comment that mails to another address using the details entered into the form as the details appearing in the respective boxes in the email.

    I don't have PHP enabled hosting, and I've read html email forms are to be avoided. My problem is I don't know anything about any other languages other than html + css. I did a search here and on google but didn't find much that helped my situation, only stuff about cgi-bin and perl, although I'm really stumped when it comes to that. If anyone has sample code for what I want and could advise me on how to implement it, I would be immensely grateful.

    Thanks,

    -Tech =o

  2.  

  3. #2
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,720
    Member #
    5580
    Liked
    718 times
    In your html form, you'll want to have the <form> line
    with the action to the name of your Perl (CGI) script, and
    the method is POST....

    Example: <form action='myemail.pl' method='post'>

    Perl scripts can have extensions of .cgi or .pl (it doesn't matter).

    Now, you'll have to use an FTP program to upload the Perl script
    into your directory called "cgi-bin" ...

    Before you upload it, you'll need to change a few lines in the script to
    make it work for your email, and the text you want. Also, you need to
    match the variables in the script with the same variables you have in
    your HTML form ... such as: name, email, phone, message, etc.

    When you decide to actually upload the script into your cgi-bin, you'll need
    to set your FTP program to upload in ASCII mode (not binary, which is usually
    the default mode).

    Once you upload the script, you need to use your FTP program to set permissions
    to the script. Each FTP program is different, but look for something that mentions
    CHMOD, or Permissions ... the CHMOD setting for the script is: 755

    Here's a copy of the Perl script for you to customize...
    Couple of important things ...
    1) Your email address is in the script, don't put your email address in your form.
    2) Your subject is in the script, don't let people enter their own subject.
    3) the line #!/user/bin/perl must be the first line of the script.
    4) Add more lines, change variables, etc ... but make sure you don't make
    typing mistakes ... missing quotes, or semicolons. Any typos will cause the
    script to fail.
    5) Lines with # signs in front are comment lines.
    6) Where you put your email address, put that backslash before \@

    Copy the whole script and paste into a Notepad text file, save it as "myemail.pl" or
    some filename with the extension of .cgi or .pl



    #!/usr/bin/perl

    use CGI ':standard';

    ################################################## ######
    # This is the location of the send mail program on
    # your server ... this is the most common path,
    # so try this...
    $mailprogram = '/usr/sbin/sendmail';

    $myemail = "youremail\@aol.com"; #<--- Your email address
    $redirect = "http://www.yoursite.com"; #<-- Where to go after the email is sent
    $subject = "Put the subject of your email here";

    ################################################## ######
    #Get Variables from your HTML form ... these must match the same names.

    $email = param('email');
    $name = param('name');
    $phone = param('phone');
    $message = param('message');

    # Send e-mail to you
    open (MAIL, "|$mailprogram -t") or die "Can't fork sendmail.\n";
    print MAIL "To: $myemail\n";
    print MAIL "From: $email\n";
    print MAIL "Subject: $subject\n";
    print MAIL "\n";
    print MAIL "Name: $name\n";
    print MAIL "Phone: $phone\n";
    print MAIL "=======================================\n";
    print MAIL "$message\n\n";
    print MAIL "=======================================\n";
    print MAIL "\n";
    close(MAIL);

    # Email sent, go to a thankyou web page...
    print "Location: $redirect\n\n";


  4. #3
    Senior Member Tech0rz's Avatar
    Join Date
    Aug 2004
    Location
    Northwest, Eng
    Posts
    128
    Member #
    7314
    Excellent thanks alot.

    I've edited the script, changed the upload mode and uploaded the script to the 'cgi-bin' directory.

    I found where it said CHMOD, and it had a few drop down boxes. One for Owner, Group and Other. The permissions were a mixture of Read, Execute and Write. I figured out what 755 meant and set them using the drop down boxes. Although when I click submit, it comes up with an error page saying:

    ---------------------------------------------------------------------
    403 Forbidden

    You don't have permission to access those file(s).
    ---------------------------------------------------------------------

    Any idea why this is happening ? (I'm using TerrapinFTP)

    Thanks,

    -Tech =o

  5. #4
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Your button would look like,
    HTML Code:
    <input type="submit" name="submit" value="E-mail me" />
    As long as the type is submit once clicked the form will be submitted to the file that is named in your action attribute of the <form> tag.

  6. #5
    Senior Member Tech0rz's Avatar
    Join Date
    Aug 2004
    Location
    Northwest, Eng
    Posts
    128
    Member #
    7314
    Hey bfsog, I did a quick google search and was able to figure it out.

    Thanks,

    -Tech =o

  7. #6
    Senior Member Tech0rz's Avatar
    Join Date
    Aug 2004
    Location
    Northwest, Eng
    Posts
    128
    Member #
    7314
    Okay, found out why I was getting the error. Quite simply, blueyonder freespace doesn't support anything fancy like php, cgi etc. I need to get this site finished quickly and get paid, but I won't be able to get hosting for a few weeks.

    Would somebody be kind enough to host this .cgi script for me? I would be very grateful.

    Thanks,

    -Tech =o

  8. #7
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,720
    Member #
    5580
    Liked
    718 times
    Use this free online service ...

    http://www.thalasson.com/

    But save all the threads above for future use ...
    You might want to reference that some other time.


  9. #8
    Senior Member Tech0rz's Avatar
    Join Date
    Aug 2004
    Location
    Northwest, Eng
    Posts
    128
    Member #
    7314
    Thanks mlseim.

    I got the form working now. I'm not too happy with the e-mail that the client receives as I would of preffered it just to simply contain 'From', 'Subject' and 'Message', rather than all those details about browser version etc. But I guess that's what you get with free services. I'll hopefully be buying proffesional web hosting soon so I'll try with the cgi script then.

    Thanks for your help everyone,

    -Tech =o

  10. #9
    Senior Member Tech0rz's Avatar
    Join Date
    Aug 2004
    Location
    Northwest, Eng
    Posts
    128
    Member #
    7314
    Ok, I'm trying to get the original form working again, because I need more options than the ones provided by the free service. I have the script uploaded (kindly hosted by bfsog), but I'm getting an error message:

    Internal Server Error

    The server encountered an internal error or misconfiguration and was unable to complete your request.

    Please contact the server administrator, webmaster@domain.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

    More information about this error may be available in the server error log.

    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
    Any ideas why?

    Here's the script code for 'myform.cgi':

    Code:
    #!/usr/bin/perl
    
    use CGI ':standard';
    
    $mailprogram = '/usr/sbin/sendmail';
    
    $myemail = "myemail\@hotmail.com";
    $redirect = "http://www.website.co.uk/thankyou.html";
    $subject = "Where do babies come from?";
    
    $name = param('name');
    $email = param('email');
    $phone = param('phone');
    $lesson = param('lesson');
    $postcode = param('postcode');
    $message = param('message');
    
    open (MAIL, "|$mailprogram -t") or die "Can't fork sendmail.\n";
    print MAIL "To: $myemail\n";
    print MAIL "From: $email\n";
    print MAIL "Subject: $subject\n";
    print MAIL "\n";
    print MAIL "Name: $name\n";
    print MAIL "\n";
    print MAIL "Telephone: $phone\n";
    print MAIL "\n";
    print MAIL "Lesson: $lesson\n";
    print MAIL "\n";
    print MAIL "Postcode: $postcode\n";
    print MAIL "\n";
    print MAIL "=======================================\n";
    print MAIL "$message\n\n";
    print MAIL "=======================================\n";
    print MAIL "\n";
    close(MAIL);
    
    print "Location: $redirect\n\n";
    Here's the html:

    Code:
    <form method="post" action="http://bfsog.co.uk/myform.cgi">
    Your name: <input name="name">
    E-mail address: <input name="email">
    Contact number: <input name="phone">
    Lesson type: <select name="lesson">
        <OPTION VALUE="" selected="selected">
        <OPTION VALUE="01">Option 1</option>
        <OPTION VALUE="02">Option 2</option>
        <OPTION VALUE="03">Option 3</option>
        <OPTION VALUE="04">Option 4</option>
    </SELECT>
    Postcode <input name="postcode">
    Comments <textarea name="message" rows="5" cols="43"></textarea>
        <input type="submit" value="Send" class="button">
        <input name="RESET" type="RESET" class="button" value="Clear form">
    </form>
    Any insight into what the problem might be?

    Thanks,

    -Tech =o

  11. #10
    WDF Staff mlseim's Avatar
    Join Date
    Apr 2004
    Location
    Cottage Grove, Minnesota
    Posts
    7,720
    Member #
    5580
    Liked
    718 times
    Here's this line:
    <form method="post" action="http://bfsog.co.uk/myform.cgi">


    But isn't the Perl script in the cgi-bin?

    <form method="post" action="http://bfsog.co.uk/cgi-bin/myform.cgi">



    ... oh, and here's the answer to your subject::classic:
    http://www.google.com/search?q=where...3F&btnG=Search



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 09:24 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com