Lunarpages Web Hosting Forum

Author Topic: novice.cgi help!!!!  (Read 7825 times)

leighsww

  • Guest
novice.cgi help!!!!
« Reply #15 on: January 04, 2004, 06:07:30 PM »
That will definitely get rid of the "File Not Found" error for the 500.shtml file, but that 500 file is probably only accessing due to the first error which is probably a scripting error.

"Premature end of script headers: /home/slavic2/public_html/cgi-bin/novice.cgi"

Have any ideas?  I'm pretty sure if he changes the \@ to remove the backslash, it may work then.  What do you think?

Danielle

  • Guest
novice.cgi help!!!!
« Reply #16 on: January 04, 2004, 06:32:31 PM »
I would think that would be the case as well, since I can find no reason whatsoever to have a backslash there other than the fact the script says to have it there.

Offline Ed

  • Berserker Poster
  • *****
  • Posts: 5156
    • Joke A Whenever
novice.cgi help!!!!
« Reply #17 on: January 04, 2004, 07:21:26 PM »
For: $sendto = "orderforms@slavicmarket.biz"

You NEED to indicate the @ is just that an @.. not an @array. The / (or is it a \) indicates its just a character and not an array.

The 500.shtml is just your error page default location. You dont neccessarily have to set it up. But I would recommend doing so, just to avoid that second annoyying error.

- Ed

Offline SlavicMarket

  • Trekkie
  • **
  • Posts: 13
novice.cgi help!!!!
« Reply #18 on: January 04, 2004, 07:58:57 PM »
I've created file :/home/slavic2/public_html/500.shtml but still doesnt work...
Everytime I keep getting the same error in the error log

 
Premature end of script headers: /home/slavic2/public_html/cgi-bin/novice.cgi
File does not exist: /home/slavic2/public_html/500.shtml

Offline Ed

  • Berserker Poster
  • *****
  • Posts: 5156
    • Joke A Whenever
novice.cgi help!!!!
« Reply #19 on: January 04, 2004, 08:16:06 PM »
You need to enable the error pages in CPanel. There should be a link for something along the line of error pages. You just have to enable it, and it should work! :-)

- Ed

Offline SlavicMarket

  • Trekkie
  • **
  • Posts: 13
novice.cgi help!!!!
« Reply #20 on: January 04, 2004, 09:05:23 PM »
ok, I got it running (almost)
There is not more error page and all is smooth... however, I dont receive the email.

What should I do about that?


leighsww

  • Guest
novice.cgi help!!!!
« Reply #22 on: January 04, 2004, 09:11:37 PM »
Post your revised script, so we can see what changes you made to that, too.

Offline SlavicMarket

  • Trekkie
  • **
  • Posts: 13
novice.cgi help!!!!
« Reply #23 on: January 04, 2004, 09:16:17 PM »
I checked the HTML, all seems to be correct. I get the success page and everything... even missing fields page shows up if not properly filled out... but just doesnt show in the email.
Here is the script:
-----------------------------------------------------------------------------------

#!/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      mail@sethknorr.com                    ##
##                                                                                      ##
##                       http://www.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: http://www.noviceforms.com/                                  ##
##                                                                                      ##
##                                                                                      ##
##  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 = "orderforms\@slavicmarket.biz";   ## (REMEMBER THE \ BEFORE THE @ SIGN)##

   $ccto = "orderforms\@slavicmarket.biz";        ## (REMEMBER THE \ BEFORE THE @ SIGN)##


## $mailprog  Is the path to sendmail or your SMTP server - on your server or web space ##

        $mailprog = "/usr/sbin/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.slavicmarket.biz", "http://slavicmarket.biz", "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") {
&
}else{
&get_form_data;
&
}

sub nopost {

print "Content-type: text/html\n\n";

print <<"MYMAINtext";

<html>

<head>
<title>Novice Forms & & & &  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 & & & & & & &  Version 1.1<br><br>

 & 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> http://www.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|\&|\&\;|g;
                $value =~ s|<|\<\;|g;
                $value =~ s|>|\>\;|g;
                $value =~ s|\n|<br>\n|g;

      push (@POST,$name);
      push (@POST,$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  ##


         &


         if (! $POST{'success_page'}){
         &
         }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{


   $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;



} ## END &

Offline SlavicMarket

  • Trekkie
  • **
  • Posts: 13
novice.cgi help!!!!
« Reply #24 on: January 04, 2004, 09:51:05 PM »
Ok, when I cc to an email not located on the server it goes thru... however info doesnt go thru with th email.

I simply get a blank email in my inbox... any ideas?

leighsww

  • Guest
novice.cgi help!!!!
« Reply #25 on: January 04, 2004, 09:51:30 PM »
What's the URL to your order form?

Offline SlavicMarket

  • Trekkie
  • **
  • Posts: 13
novice.cgi help!!!!
« Reply #26 on: January 04, 2004, 09:56:42 PM »

leighsww

  • Guest
novice.cgi help!!!!
« Reply #27 on: January 04, 2004, 09:58:27 PM »
I looked at the documentation for the script and you might be missing the $useLib line:

Here's what the documentation said regarding that ...

------------------------------
Quote

$useLib

$useLib defines the method of sending the form info to your email.  

Example: To send mail via SENDMAIL (Most Common):
$useLib = "sendmail";

OR - To send mail via SMTP server:
$useLib = "smtp";
------------------------------
$mailprog

Used only if you set ( $useLib = "sendmail"; )
Enter the path to sendmail on your server.
Example:
$mailprog = "/usr/lib/sendmail";
------------------------------
$smtp

Used only if you set ( $useLib = "smtp"; )
Enter the path to your SMTP server.
Example:      
$smtp = "smtp.host.com";  
------------------------------


*edited - make sure to leave the $mailprog="/usr/sbin/sendmail" as you already have it because that's the path for LP's server.  Just add the $useLib line.

Offline SlavicMarket

  • Trekkie
  • **
  • Posts: 13
novice.cgi help!!!!
« Reply #28 on: January 04, 2004, 10:03:48 PM »
I dont know what you mean...

I receive the email... It goes thru... but all I get is the date the senders email (one of the fields) and their IP, the here's what the email looks like:

The form below was submited by asdf@asdfc.com form Ip address: 207.6.253.212 on January 4, 2004 at 21:45
-------------------------------------------------------------------------

leighsww

  • Guest
novice.cgi help!!!!
« Reply #29 on: January 04, 2004, 10:05:55 PM »
That's what the documentation says at http://www.noviceforms.com/readmev1_1.txt

Also, I do notice that your html form does not have the hidden tags for your info.  That is why your info is not getting shown back to you in the email.

Go to the link above and you will need to see how the hidden tags in your html need to be.