49 users online (1 members and 48 guests)  


  Results 1 to 2 of 2

Related

  1. CGI script doesnt run properly    Forum: CGI Perl Forum
    Replies: 0
  2. Replies: 4
  3. Replies: 1
  4. Ie5 and Ie6 ... 100% with doesnt work!    Forum: HTML Forum
    Replies: 6
  5. My form won't work and...    Forum: HTML Forum
    Replies: 10
  1. #1
    dmnpatrick's Avatar
    New User

    Status
    Offline
    Join Date
    Jan 2008
    Posts
    1

    Angry CGI form processor configured? and doesnt work. HELP PLEASE!!!

    HI.
    I've got the form ready, with an action pointing to cgi form processor.

    here:
    webbiz2.com/form.html
    l

    and then there is a cgi file:

    webbiz2.com/cgi-bin/novice.cgi

    it has the right permission(755). and error message shows up:
    [an error occurred while processing this directive].
    DId i do something wrong configuring cgi file or is it something else. help me please. Below is an actual cgi code:


    Code:
    #!/usr/bin/perl
    ## make sure the path to pearl is correct above. ##
     
    ##########################################################################################
    ## FILE: novice.cgi ##
    ## ##
    ## Novice Forms Version 1.1 ##
    ## © Copyright 2000-2003 Seth Michael Knorr ##
    ## ##
    noviceforms.com
    ## Please contact me with any bugs found, or any bug fixes. ##
    ## ##
    ## This script is a spin off of the original ©Biz Mail Form ##
    ## ##
    ##########################################################################################
    ## ##
    ## There is no email support provided for this script, the only support can be ##
    ## found at our web site: ##
    ## ##
    ## ##
    ## ANY PERSON(S) MAY USE AND MODIFY THESE SCRIPT(S) FREE OF CHARGE FOR EITHER BUSINESS ##
    ## OR PERSONAL, HOWEVER AT ALL TIMES HEADERS AND COPYRIGHT MUST ALWAYS REMAIN IN TACT. ##
    ## ##
    ## REDISTRIBUTION FOR PROFIT IS PROHIBITED WITH OUT THE CONSENT OF SETH KNORR. ##
    ## ##
    ## By using this code you agree to indemnify Seth M. Knorr from any liability that ##
    ## might arise from its use. ##
    ## ##
    ## ##
    ##########################################################################################
     
     
    ## $sendto and $ccto is Where form submissions will be sent, ##
    ## (REMEMBER THE \ BEFORE THE @ SIGN example: \@) ##
    ## $sendto = "sendto\@yourdomain.com"; CORRECT WAY!!!! ##
    ## $sendto = "sendto@yourdomain.com"; WILL NOT WORK!!!! ##
     
     
    $sendto = "sendto\contact@webbiz2.com"; ## (REMEMBER THE \ BEFORE THE @ SIGN)##
     
    $ccto = "cc\submit@webbiz2.com"; ## (REMEMBER THE \ BEFORE THE @ SIGN)##
     
     
     
    ## $useLib defines the method of sending the email form info to you. ##
    ## Set $useLib = "sendmail"; TO USE THE SENDMAIL METHOD ##
    ## Set $useLib = "smtp"; TO USE THE SMTP METHOD ##
     
    $useLib = "sendmail";
     
    $mailprog = "/usr/lib/sendmail"; ## $mailprog Is the path to sendmail on your server ##
     
    $smtp = "smtp.host.com"; ## Optional $smtp is your smtp server address ##
    ## example: smtp.host.com ##
    ## You only configure this is not using sendmail ##
     
     
    ## to use @okurls to verify the url the form is submited by; set $setokurl to 1 and ##
    ## set $setokurl to 0 if you do not want to use @okurls to verfiy form submission URL ##
     
    $setokurl = "0";
     
    @okurls = ("http://www.yourdomain.com", "http://yourdomain.com", "34.344.344.344");
     
     
     
    ####################################################################################################
    ############# #############
    ############# N O N E E D T O E D I T A N Y V A R I A B L E S B E L O W #############
    ############# #############
    ####################################################################################################
     
     
    my($offset) = @_;
    $offset = $offset * 86400;
     
    my($sec, $min, $hour, $dayofmonth, $mon, $year, $weekday, $dayofyear, $IsDST) = localtime(time + $offset);
    $year = $year + 1900;
    my(@months) = ("JA", "FB", "MR", "AP", "MY", "JN", "JL", "AG", "SP", "Oc", "NV", "DE");
    my($monthname) = $months[$mon];
    my(@monthsnum) = ("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12");
    my($monthnamenum) = $monthsnum[$mon];
     
    my(@monthsactual) = ("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
    my($monthnameactual) = $monthsactual[$mon];
     
     
    my(@days) = ("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday");
    my($dayname) = $days[$weekday-1];
     
    ${'monthname'} = "$monthname";
    ${'monthnamenum'} = "$monthnamenum";
    ${'dayofmonth'} = "$dayofmonth";
     
    ${'hour'} = "$hour";
     
    if ($hour <= 13){
    $hour = "$hourplus";
    $newhour = ($hourplus-12);
     
    }else{
    $newhour = "$hour";
    }
     
     
    if ($min <= 9){
    $newmin = "0$min";
    }else{
    $newmin = "$min";
    }
     
     
    $footer = "<br><br><br><br><br><center><font face='Arial'><a href='http://www.noviceforms.com/' target='_blank'><font color='#ff0000'>Form processing script provided by Novice Forms</font></a> </center></font>";
     
    $backbutton = "<br><br><b>Hit your browsers back button and resubmit the form.</b>";
     
    if($ENV{'REQUEST_METHOD'} eq "GET") {
    &nopost;
    }else{
    &get_form_data;
    &main;
    }
     
    sub nopost {
     
    print "Content-type: text/html\n\n";
     
    print <<"MYMAINtext";
     
    <html>
     
    <head>
    <title>Novice Forms &nbsp; &nbsp; &nbsp; &nbsp; Version 1.1 </title>
    </head><body bgcolor="#cfcfcf">
    <center>
     
     
    <table width=500 border=1><tr><td bgcolor="#000080">
    <br><br>
    <font face="Arial" color="#ffffff">
    <center>
    Novice Forms &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Version 1.1<br><br>
     
    &copy; Copyright 2000-2003 Seth Knorr<br><br>
    A free download of this script can be found at: <a href="http://www.noviceforms.com/" target="_blank"> <font color="#ff0000"><b> noviceforms.com </b></font></a>
    </font></center>
    <br><br>
    </td></tr></table>
    </center>
     
    </body></html>
     
    MYMAINtext
     
    exit;
     
    }
     
     
    sub get_form_data {
     
     
    read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
    @pairs=split(/&/,$buffer);
    foreach $pair (@pairs)
    {
    @a = split(/=/,$pair);
    $name=$a[0];
    $value=$a[1];
    $value2=$a[1],;
    $name =~ s/\+/ /g;
    $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
    $value =~ s/~!/ ~!/g;
    $value =~ s/\+/ /g;
    $value =~ s/(\r)+/\-\-/g;
    $value =~ s/\n+//g;
    $value =~ s/(\-\-)+/\n/g;
    $value =~ s|\&|\&amp\;|g;
    $value =~ s|<|\&lt\;|g;
    $value =~ s|>|\&gt\;|g;
    $value =~ s|\n||g;
    $value =~ s|\r||g;
    $value =~ s|To:|to|g;
    $value =~ s|Cc:|cc|g;
    $value =~ s|Bcc:|bcc|g;
     
    push (@POST,$name);
    push (@POST,$value);
    push (@formname,$name);
    push (@formvalue,$value);
     
    }
    %POST=@POST;
    %POST;
    %formname=@formname;
    %formname;
    %formvalue=@formvalue;
    %formvalue;
     
     
    }
     
     
    sub main {
     
    @sortfields = split(/,/,$POST{'sort'});
     
    @required = split(/,/,$POST{'required'});
     
    for ($indexreq = 0; $indexreq < @required; $indexreq++) {
    $myrequired = $required[$indexreq];
    $myformreq = $POST{"$myrequired"};
     
     
    if ($myrequired eq "email"){
    if (!$myformreq || $myformreq =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ || $myformreq !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z0-9]+)(\]?)$/){
    &missing_email;
    }
    }
    elsif (!$myformreq){
    &format_error;
    }
     
    }
     
     
    ## START $setokurl ##
     
    if ($setokurl =~ /1/){
     
    $url = "0";
    $referer = "$ENV{'HTTP_REFERER'}";
     
     
    foreach $myokurls (@okurls) {
    if ($referer =~ /$myokurls/) {
    $url = "1";
    }
     
    }
    if ( $url == 0) {
     
    &bad_okurl;
    }
     
    }
     
     
    ## END $setokurl ##
     
     
    &notify;
     
     
    if (! $POST{'success_page'}){
    &success;
    }else{
    print "Location: $POST{'success_page'}\n\n";
    }
     
     
     
    } ## END "SUB MAIN" ##
     
    sub success {
     
     
    print "Content-type: text/html\n\n";
     
    print <<"Myformatsuccess";
     
    <html>
    <head>
    <title>Thank You.</title>
    </head>
    <body>
    <BR><BR><CENTER>
    <h2>Your form has been submitted successfully!</h2>
     
     
    </CENTER>
     
     
    $footer
     
    </body>
    </html>
     
    Myformatsuccess
     
     
    exit;
     
    }
     
     
    sub missing_email {
     
    $title = "<title>Missing or invalid format of email!</title>";
    $errormessage = "<h2>Missing or invalid format of email.</h2><b>The email Field must be filled in and in the proper format!</b>";
     
    print "Content-type: text/html\n\n";
     
    print <<"missingemailERROR";
     
    $title
     
    $errormessage
     
    $backbutton
     
    $footer
     
    missingemailERROR
     
    exit;
     
    }
     
     
    sub bad_okurl {
     
    $title = "<title>Invalid Reffering URL.</title>";
    $errormessage = "<h2>Invalid Referring URL.</h2><b>If you are the administrator, edit the \@okurls in the novice.cgi script or turn this feature off.</b>";
     
     
    print "Content-type: text/html\n\n";
     
    print <<"badurlERROR";
     
    $title
    $errormessage
    $footer
     
    badurlERROR
     
    exit;
     
    }
     
     
     
    sub format_error {
     
     
    for ($indexreq = 0; $indexreq < @required; $indexreq++) {
    $myrequired = $required[$indexreq];
    $myformreq = $POST{"$myrequired"};
     
    if (!$myformreq){
     
    $REQUIRED{"$indexreq"} = "${'LISTITEMS'}<li> $myrequired";
    ${'LISTITEMS'} = $REQUIRED{"$indexreq"};
     
    }
    }
     
     
    $title = "<title>Missing form fields!</title>";
    $errormessage = "<h2>Missing form fields!</h2><b>The Below Required Fields Where Left Blank:</b><br><br>${'LISTITEMS'}<br><br><b>Hit your browsers back button and resubmit the form.</b>";
     
    print "Content-type: text/html\n\n";
     
    print <<"MyformatERROR";
     
    $title
    $errormessage
    $backbutton
    $footer
     
    MyformatERROR
     
    exit;
     
    }
     
     
    sub notify{
     
     
    if ($useLib eq "sendmail") {
     
    #############################################
    # ABOVE CHECKS WHAT SEND TYPE TO USE #
    #############################################
     
    $msgSubject = "Novice Form Submission" . "$POST{'subject'}";
     
    open(MAIL, "|$mailprog -t") || die "Can't open $mailprog!\n";
    print MAIL "To: $sendto\n";
    if ($ccto){
    print MAIL "Cc: $ccto\n";
    }
    print MAIL "From: $POST{'email'}\n";
    print MAIL "Subject: $msgSubject\n";
    print MAIL "The form below was submited by $POST{'email'} form Ip address: $ENV{'REMOTE_ADDR'} on $monthnameactual $dayofmonth, $year at $newhour:$newmin\n";
    print MAIL "-------------------------------------------------------------------------\n\n";
     
     
    if (! $POST{'sort'}) {
     
     
    for ($indexval = 0; $indexval < @formvalue; $indexval++) {
    ${'myname'} = $formname[$indexval];
    ${'myvalue'} = $formvalue[$indexval];
     
     
    if (${'myname'} eq "subject" || ${'myname'} eq "required" || ${'myname'} eq "sort" || ${'myname'} eq "success_page" || ${'myname'} eq "ccto" || ${'myname'} eq "sendto"){
    $dontrun = "1";
    }else{
    $dontrun = "";
    }
     
    if (! $dontrun){
    print MAIL "${'myname'}: ${'myvalue'} \n\n";
    }
    }
     
    }else{ ##ELSE IF NO SORT FIELD ##
     
    for ($numsort = 0; $numsort < @sortfields; $numsort++) {
    $sfield = $sortfields[$numsort];
    ${'sfieldvalue'} = $POST{"$sfield"};
    ${'sfield'} = "$sfield";
     
    print MAIL "${'sfield'}: ${'sfieldvalue'} \n\n";
     
    }
     
    } ## END ELSE IF SORT FIELD ##
     
    close MAIL;
     
     
    #########################
    }else{ # END IF SENDMAIL #
    #########################
     
     
    $msgSubject = "Novice Forms Submission" . "$POST{'subject'}";
     
    $nl = "\n";
    $msgMessage = "";
     
    $msgMessage=$msgMessage.$POST{'message'}.$nl.$nl.$nl;
    $msgMessage=$msgMessage."The form below was submitted by ";
    $msgMessage=$msgMessage.$POST{'email'}." Ip address: ".$ENV{'REMOTE_ADDR'};
    $msgMessage=$msgMessage." ".$monthnameactual." ".$dayofmonth.", ".$year;
    $msgMessage=$msgMessage." at ".$hour.":".$min.$nl;
    $msgMessage=$msgMessage."-------------------------------------------------------------------------".$nl.$nl;
     
     
    if (! $POST{'sort'}) {
     
    for ($indexval = 0; $indexval < @formvalue; $indexval++) {
    ${'myname'} = $formname[$indexval];
    ${'myvalue'} = $formvalue[$indexval];
    if (${'myname'} eq "subject" || ${'myname'} eq "required" || ${'myname'} eq "sort" || ${'myname'} eq "success_page" || ${'myname'} eq "ccto" || ${'myname'} eq "sendto"){
    $dontrun = "1";
    }else{
    $dontrun = "";
    }
    if (! $dontrun) {
    $msgMessage= $msgMessage.${'myname'}.": ".${'myvalue'}.$nl;
    }
    }
     
    }else{ ##ELSE IF NO SORT FIELD ##
     
    for ($numsort = 0; $numsort < @sortfields; $numsort++) {
    $sfield = $sortfields[$numsort];
    ${'sfieldvalue'} = $POST{"$sfield"};
    ${'sfield'} = "$sfield";
     
    $msgMessage .= "${'sfield'}: ${'sfieldvalue'} \n\n";
     
    }
     
    } ## END ELSE IF SORT FIELD ##
     
     
     
    $msgformat = "text/plain";
     
    eval { require(Net::SMTP)};
    if ($@) {
    print "Failed to load";
    exit;
    }
     
    ## send email results##
    $smtp = Net::SMTP->new($smtp); # connect to an SMTP server #
    $smtp->mail($formdata{'email'}); # use the sender's address here #
    $smtp->to ($sendto); # recipient's address #
    $smtp->data(); # Start the mail #
     
    $smtp->datasend("To: ".$sendto."\n");
    $smtp->datasend("From: $formdata{'email'}\n");
    $smtp->datasend("Subject: $msgSubject\n");
    $smtp->datasend("Content-Type: ".$msgformat);
    $smtp->datasend("\n\n");
    $smtp->datasend($msgMessage."\n");
    $smtp->datasend("\n");
    $smtp->datasend("\n");
    $smtp->datasend("\n");
    $smtp->datasend("\n");
     
    $smtp->dataend(); # Finish sending the mail #
    $smtp->quit; # Close the SMTP connection #
     
     
     
     
    #########################
    } # END IF SMTP ELSE #
    #########################
     
     
    } ## END &notify;



    THANKS AGAIN.
    DAmien
    Last edited by HTML; 01-10-2008 at 07:33 AM. Reason: insert code tags

  2. #2
    vamshi's Avatar
    New User

    Status
    Offline
    Join Date
    Nov 2007
    Posts
    13

    Re: CGI form processor configured? and doesnt work. HELP PLEASE!!!

    check the following line of code
    #!/usr/bin/perl
    is this the correct interpreter path for u r application... please check once.



Tags for this Thread