Ack! need a little CGI help here...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Anthony
    Member
    • Apr 2004
    • 30

    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="www@youradds.com">

    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="http://www.vgacd.com">


    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??


    Cheers,
    Anthony
    Last edited by Anthony; 11-02-2004, 12:40 AM.
  • halyfax
    Senior Member
    • Mar 2004
    • 124

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

    Comment

    • Jonathan
      Senior Member
      • Mar 2004
      • 1229

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

      PHP Code:
      <?php

      // 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 "address@Email.com";    // 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");
      echo 
      "Thank you for contacting *site name*; we will shortly<br>";
      echo 
      "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 {
          
      echo 
      "<form action=\"{$_SERVER['PHP_SELF']}\" method=\"post\">";
      echo 
      "Your Name (required): <br> <input type=\"text\" name=\"name\" size=\"50\"><br>";
      echo 
      "Your Email Address (required): <br> <input type=\"text\" name=\"email\" size=\"50\"><br>";
      echo 
      "Your Business Name (if applies, not required) <br> <input type=\"text\" name=\"biz\" size=\"50\"><Br>";
      echo 
      "Your State (not required) <br> <select name=\"state\">
      <option selected value=\"-- Select One --\">-- Select One --</option>
                <option>AL</option>
                <option>AK</option>
                <option>AR</option>

                <option>AZ</option>
                <option>CA</option>
                <option>CO</option>
                <option>CT</option>
                <option>DE</option>
                <option>FL</option>

                <option>GA</option>
                <option>HI</option>
                <option>IA</option>
                <option>ID</option>
                <option>IL</option>
                <option>IN</option>

                <option>KS</option>
                <option>KY</option>
                <option>LA</option>
                <option>MA</option>
                <option>MD</option>
                <option>ME</option>

                <option>MI</option>
                <option>MN</option>
                <option>MO</option>
                <option>MS</option>
                <option>MT</option>
                <option>NC</option>

                <option>ND</option>
                <option>NE</option>
                <option>NH</option>
                <option>NJ</option>
                <option>NM</option>
                <option>NV</option>

                <option>NY</option>
                <option>OH</option>
                <option>OK</option>
                <option>OR</option>
                <option>PA</option>
                <option>RI</option>

                <option>SC</option>
                <option>SD</option>
                <option>TN</option>
                <option>TX</option>
                <option>UT</option>
                <option>VI</option>

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

          }
      ?>
      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*", "address@email.com" etc.
      Last edited by Jonathan; 10-29-2004, 10:33 AM.
      "How can someone be so distracted yet so focused?"
      - C

      Comment

      • sdjl
        Senior Member
        • Mar 2004
        • 502

        #4
        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

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

        Comment

        • Anthony
          Member
          • Apr 2004
          • 30

          #5
          Thanks everyone, it works


          I removed links to my site for googl'ing reasons

          Comment

          Working...