Results 1 to 5 of 5

Thread: Ack! need a little CGI help here...

  1. #1
    Join Date
    Apr 2004

    Default Ack! need a little CGI help here...

    Okaaaaaaay, so, I got all my paths correct, chmoded properly AND uploaded in ASCII and not binary.

    The script in question :
    the page I want to use it on :
    and here's the readme file :

    How To Install:
    First of all you need to open up formmail.cgi and check that the first line of code points to the location of Perl on your server.

    Then upload template.html and formmail.cgi.

    CHMOD the .cgi files to 755, and the .html file to 666.

    Then in formmail.cgi edit the path to sendmail for your server (normal locations are, /usr/lib/sendmail, /usr/bin/sendmail or /usr/sbin/sendmail). Then upload formmail.cgi to your server again. Now we have the actual script hopefully set up correctly we need to create the forms.

    There are several HIDDEN variables that need to be defined. These are;

    recipient - This is obviously the person you want to receive the data from the submission. Example HTML code;

    <input type="hidden" name="recipient" value="">

    sendthanks - If set to 'yes' (case sensitive) then the email address submitted by the will be sent a 'received' email to confirm their email has been submitted. Example HTML code;

    <input type="hidden" name="sendthanks" value="yes">

    subject - If left blank (or not entered) this will be replaced with 'Form Submission'. Example HTML code;

    <input type="hidden" name="subject" value="Form From somepage.html">

    redirect - This is where the user will be sent to once the email(s) have been sent. If left blank a 'Thanks' page will be shown to confirm the sending. You can edit the look of the submission template very easily by editing the HTML in template.html. Where you want the code to appear just put message where you want the content to appear. The template is thus very customizable! Example HTML code;

    <input type="hidden" name="redirect" value="">

    There are also a couple of text boxes that need to exist for it to work correctly. These are identified below;

    name - This is so you know what to call them when replying to submissions. It is also checked to see if it is left blank. Example HTML code;

    <input type="text" name="name" size="20">

    email - This is their e-mail. If left blank an error message will be shown. It also checks to see if the format is correct. Example HTML code;

    <input type="text" name="email" size="20">

    Now, I have ALL that in there already, why won't it work??

    Last edited by Anthony; 11-01-2004 at 11:40 PM.

  2. #2
    Senior Member
    Join Date
    Mar 2004


    I would suggest using this formmail script. It is very secure and stable and easy to install

  3. #3
    Senior Member Jonathan's Avatar
    Join Date
    Mar 2004
    Daytona Beach, FL / Rochester, NY / Coeur d'Alene, ID


    Or you could make a simple PHP one
    Here's a sample one I wiped up from one of mine..

    PHP Code:

    // Checks if the form was submitted, if so process it
    if (isset($submit)) {
    $name $_POST['name'];            // 'name' field
    $email $_POST['email'];        // 'email' field
    $biz $_POST['biz'];            // 'business' field
    $state $_POST['state'];        // 'state' field
    $find $_POST['find'];            // 'found out about' field
    $message $_POST['message'];    // 'message' field
        // Checks if each of the 'required' fields are empty; if so, let them now    
    if (empty($name)) $error[]="You did not fill out the contact form completely; please go back and correct this!";
            if (empty(
    $email)) $error[]="You did not fill out the contact form completely; please go back and correct this!";
            if (empty(
    $message)) $error[]="You did not fill out the contact form completely; please go back and correct this!";
    // If there are no errors, go ahead and actually process the script
    if (isset($error)==false)
    $to "";    // Email address its going to
    $subject "Feedback from ...";    // Subject field
    $msg "Name: $name\nEmail: $email\nBusiness Name: $biz\nState :$state\nFound out about Gamer Designs: $find\n\nMessage:\n $message";    // Message itself
    // Let's send the mail, then echo our thanks and let them know we care
    mail($to,$subject,$msg"From: $email");
    "Thank you for contacting *site name*; we will shortly<br>";
    "reply to your email, usually within 24-48 hours.";

        } else foreach (
    $error as $msg) echo $msg.'<br>';
    // Its done, but if the field wasn't submitted, show it then
    } else {
    "<form action=\"{$_SERVER['PHP_SELF']}\" method=\"post\">";
    "Your Name (required): <br> <input type=\"text\" name=\"name\" size=\"50\"><br>";
    "Your Email Address (required): <br> <input type=\"text\" name=\"email\" size=\"50\"><br>";
    "Your Business Name (if applies, not required) <br> <input type=\"text\" name=\"biz\" size=\"50\"><Br>";
    "Your State (not required) <br> <select name=\"state\">
    <option selected value=\"-- Select One --\">-- Select One --</option>








    "How did you find *site name*? (not required) <br> <input type=\"text\" name=\"find\" size=\"50\"><br>";
    "Your Message: <br> <textarea rows=\"10\" cols=\"45\" name=\"message\"></textarea><br><Br>";
    "<input type=\"submit\" name=\"submit\" value=\"Submit\"> - <input type=\"reset\" name=\"reset\" value=\"Clear\">";

    Note though, I used $PHP_SELF which is somewhat bad;
    I replaced it with {$_SERVER['PHP_SELF']} which I think is correct.

    If not, try replacing {$_SERVER['PHP_SELF']} with $PHP_SELF
    Make the changes such as "*site name*", "" etc.
    Last edited by Jonathan; 10-29-2004 at 09:33 AM.
    "How can someone be so distracted yet so focused?"
    - C

  4. #4
    Senior Member sdjl's Avatar
    Join Date
    Mar 2004
    London, UK.


    A couple of things to add to Jonathan' script.

    Use $_SERVER['PHP_SELF'] for the form action.

    I've noticed in the past that adding additional headers to the mail command help it get delivered.
    AOL has issues if you only use the From: tag.
    Try adding in these too.
    PHP Code:
    $header "MIME-Version: 1.0\n" ;
    $header .= "From: ".$yemail."\n";
    $header .= "Reply-To: ".$yemail."\n";
    $header .= "X-Sender: ".$yemail."\n";
    $header .= "X-Mailer: PHP\n";
    $header .= "X-Priority: 3\n";
    $header .= "Return-Path: ".$yemail."\n"
    There are a few other things that i wouldn't personally do, but the script as it stands will work with them, that's just my coding ethics

    Do you fear the obsolescence of the metanarrative apparatus of legitimation?

  5. #5
    Join Date
    Apr 2004


    Thanks everyone, it works

    I removed links to my site for googl'ing reasons

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