Lunarpages Web Hosting Forum

Scripting Languages Hosting Help => C++ / PERL / CGI Support => Topic started by: SlavicMarket on January 04, 2004, 03:02:50 PM

Title: novice.cgi help!!!!
Post by: SlavicMarket on January 04, 2004, 03:02:50 PM
:?
Can someone please help me?
Since FormMail shut down life has been hell! My forms all worked from that script, and I couldnt be more satisfied..
I looked for alternatives, such as cgiemail, but man, that script is such a pain.

I added a new cgi script, novice.cgi... however I cant get it to work.
I got the permissions correctly, the file was uploaded as ascii, did everything by the manual of the script, but it still doesnt work. Perhaps someone know CGI and can tell me what to do? The script is below
----------------------------------------------------------------------------------

#!/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/lib/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") {
&
}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 &
---------------------------------------------------------------------------------

Thanks for your help,

Alex
Title: novice.cgi help!!!!
Post by: leighsww on January 04, 2004, 04:28:27 PM
This line ...

@okurls = ("http://www.yourdomain.com", "http://yourdomain.com", "34.344.344.344");

needs to have "yourdomain.com" replaced with your actual domain name.

Don't forget to upload in ASCII and chmod to 755.

Let's try that and see if that makes it work.  If still other problems, post again.  Make sure to post what your errors are saying so we can further narrow down the problem.
Title: novice.cgi help!!!!
Post by: leighsww on January 04, 2004, 04:31:01 PM
Okay, wait.  I see that you have your "setokurl" set to zero, so I guess that won't matter.  Try putting a # in front of the "@okurl=("http: ...) code.
Title: novice.cgi help!!!!
Post by: mark363 on January 04, 2004, 04:32:11 PM
I wonder if we'll ever actually meet the owner of "yourdomain.com" .... that'll be interesting  :|
Title: novice.cgi help!!!!
Post by: leighsww on January 04, 2004, 04:36:31 PM
Also, I see one more problem. Change ...

$mailprog = "/usr/lib/sendmail";

change to ...

$mailprog = "/usr/sbin/sendmail";

the "lib" should be "sbin".
Title: novice.cgi help!!!!
Post by: mark363 on January 04, 2004, 04:38:35 PM
leigh-- I'm surprised at you! Since when do you not use edits/Addendums the way we here at LF are so encouraged? Have you learned nothing in your 727 posts? Poor leigh... we may need that whip again...  :poke:
Title: novice.cgi help!!!!
Post by: leighsww on January 04, 2004, 04:42:21 PM
LOL ... actually, mussavcom, I didn't know you were posting at the same time as me, so I made the change at the exact same time you posted.  But, because you have faster fingers than me, you must have hit the submit just a millisecond faster.

Also, the only thing I edited on that post was "okurl" to "setokurl", so there is nothing in my post that I would have changed to make your post look dipsy.  :)

But anyway, I don't use addendums, I use * edited - as you must know by now.  :poke:
Title: nope
Post by: SlavicMarket on January 04, 2004, 04:48:37 PM
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
Title: novice.cgi help!!!!
Post by: mark363 on January 04, 2004, 04:48:37 PM
That's not what I mean...
Quote from: leighsww
Also, I see one more problem. Change ...

$mailprog = "/usr/lib/sendmail";

change to ...

$mailprog = "/usr/sbin/sendmail";

You had that post, then the one that said 'the "lib" should be "sbin".' Then, you must've deleted the second post and stuck that sentence into the first post. Unless I'm going crazy  :o , but why :o would y:o o :o u :o think th :o at? :o
Title: novice.cgi help!!!!
Post by: leighsww on January 04, 2004, 04:50:43 PM
Ha, Ha!!  Okay, you've caught me.  Take me to the whipping room.

Slavicmarket - make sure your html "action" is pointing correctly to where the script resides in your cgi-bin.

** EDITED - provide the link to your form on your website so we can check out the html code.
Title: novice.cgi help!!!!
Post by: mark363 on January 04, 2004, 04:53:10 PM
Quote from: leighsww
Slavicmarket - make sure your html "action" is pointing correctly to where the script resides in your cgi-bin.

Oh, sure, try to subtly change the subject!  :whip:  You'll pay for this!!

Using my magic powers, I have put an evil spell on you. Now, everything you buy will suddenly cost ten cents extra!!!  :poke:
Title: novice.cgi help!!!!
Post by: leighsww on January 04, 2004, 04:55:18 PM
mussavcom - stop interrupting my posts!!  You see, now every one of them has a "last edited by ..." line.  You little rascal!

Leave me alone, right now, so I can help SlavicMarket in peace!!  OR, meet me in the CHAT or FUN forum and I'll have at you there.  :poke:

*edited - oh, I've gotten off pretty cheap with just ten cents. You must not want to punish me that bad.  :love:
Title: novice.cgi help!!!!
Post by: SlavicMarket on January 04, 2004, 04:59:46 PM
Yup, doubled checked... the pathway to the script is correct...

Any other ideas?
Title: Re: nope
Post by: leighsww on January 04, 2004, 05:18:38 PM
Quote from: SlavicMarket
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


Hmmm. Okay, I know it says to not forget to put the \@, but try taking out the backslash.  I think that may only be necessary on certain types of servers.

So try ...

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

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


and see if that works.
Title: novice.cgi help!!!!
Post by: Danielle on January 04, 2004, 05:40:58 PM
Hi SlavicMarket,

I have looked at your account, and I do not see a file named 500.html in public_html.  You do get the error message:

File does not exist: /home/slavic2/public_html/500.shtml

This means that you do not have a file named 500.shtml in public_html.  Since I have already checked this is the case, you may have the file only on your local computer and need to upload it. Alternatively, you may not have created it or may have it in another folder.  Until you have this file (whatever it is supposed to do), you will continue to receive this error message.

A way to always check if a file exists or not is to simply go into your browser and type the absolute url to that file.  In this instance that would be http://slavicmarket.biz/500.shtml  This returns the same error that it wasn't found.

I hope this helps.
Title: novice.cgi help!!!!
Post by: leighsww 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?
Title: novice.cgi help!!!!
Post by: Danielle 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.
Title: novice.cgi help!!!!
Post by: Ed 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
Title: novice.cgi help!!!!
Post by: SlavicMarket 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
Title: novice.cgi help!!!!
Post by: Ed 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
Title: novice.cgi help!!!!
Post by: SlavicMarket 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?
Title: novice.cgi help!!!!
Post by: Ed on January 04, 2004, 09:09:47 PM
Have you double checked your HTML code?
Title: novice.cgi help!!!!
Post by: leighsww on January 04, 2004, 09:11:37 PM
Post your revised script, so we can see what changes you made to that, too.
Title: novice.cgi help!!!!
Post by: SlavicMarket 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 &
Title: novice.cgi help!!!!
Post by: SlavicMarket 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?
Title: novice.cgi help!!!!
Post by: leighsww on January 04, 2004, 09:51:30 PM
What's the URL to your order form?
Title: novice.cgi help!!!!
Post by: SlavicMarket on January 04, 2004, 09:56:42 PM
http://www.slavicmarket.biz/form.html
Title: novice.cgi help!!!!
Post by: leighsww 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.
Title: novice.cgi help!!!!
Post by: SlavicMarket 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
-------------------------------------------------------------------------
Title: novice.cgi help!!!!
Post by: leighsww 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.
Title: novice.cgi help!!!!
Post by: leighsww on January 04, 2004, 10:16:49 PM
Okay, here's something weird.  I took your source code and entered it into Dreamweaver so I can see everything better.  I didn't see where your hidden tags where via Dreamweaver, but when I look at your source code via text editor, it's there.

Let me look at this more closely and I'll get back to you.
Title: novice.cgi help!!!!
Post by: SlavicMarket on January 04, 2004, 10:19:06 PM
I tried adding the uselib line, however it simply took over the mailprog, there was no change... still same problem

I am not sure what you mean by my hidden tags being absent... the are just lower becuase the form starts after the picture...  
this is what they look like, perhaps you can see an error?:

<form method="post" action="http://www.slavicmarket.biz/cgi-bin/novice.cgi">
<input type="hidden" name="subject" value="CD Order">
<input type="hidden" name="success_page" value="http://www.slavicmarket.biz/thanks.html">
<input type="hidden" name="required" value="lastname,firstname,address,city,state,country,zip,email">
Title: novice.cgi help!!!!
Post by: leighsww on January 04, 2004, 11:40:15 PM
This is a dilemma.  Okay, I found this page ...

http://www.noviceforms.com/faq.phtml

If you can't find any help with that info, then here are some other suggestions:

1) try adding the "sort" variable/tag to your html.
2) try changing from "sendmail" to "SMTP" settings and see what happens.
3) download the script again from the original source to make sure that something wasn't accidentally altered that is needed.
Title: novice.cgi help!!!!
Post by: SlavicMarket on January 05, 2004, 04:09:58 PM
I wrote an email to the creator of the scritp, here is what he had to say. I am not sure what that means and what I have to change and where. Can you help?
----------------------------------------------------------------------------------

It could be that your server has either a realy
old build of Linux or Windows, or has variables turned
off. Because it would seem that your server is not
picking up the PERL variable: $ENV{'CONTENT_LENGTH'}

Which should cary all POST variables.

If you send me the form url location I will take a
look at it, but this seems to be the problem. I would
check with either your host or system administrartor
for addititional help.

Seth
Title: novice.cgi help!!!!
Post by: leighsww on January 05, 2004, 04:22:47 PM
I use the bnbform.cgi script and have that variable in my script, yet my forms work.

Hmmm.  Let me look at something again and I'll be back.
Title: novice.cgi help!!!!
Post by: leighsww on January 05, 2004, 04:58:34 PM
Okay, I am stumped as to what may be going wrong for you.

Have you done the 3 things that I mentioned above?

Quote
1) try adding the "sort" variable/tag to your html.
2) try changing from "sendmail" to "SMTP" settings and see what happens.
3) download the script again from the original source to make sure that something wasn't accidentally altered that is needed.


If you did and those still didn't work, then you will either:

1) need to wait for someone else to help you
2) you may want to check with tech support to find out if there is something with the server, like Seth said, or
3) the only thing I can do for you at this point is if you want to use the script I use.

At least with a script I am familiar with, I can step you through making that script work for you (unless there is something different with your server from mine).

Before you do that, though I would recommend that you backup your previous form (just name it something different) which has the hidden tags that correspond with the novice.cgi.  We don't want to get rid of it, in case you decide to switch back.

Let me know if you want to give it a shot and we'll get started.
Title: novice.cgi help!!!!
Post by: Ed on January 05, 2004, 05:03:53 PM
$ENV{'CONTENT_LENGTH'} should work fine here  :thumb:
Title: novice.cgi help!!!!
Post by: SlavicMarket on January 05, 2004, 10:19:10 PM
Thanks alot!!!
I got it working guys! Yea, I needed to add that line... I dont know how I missed it.
You guys have been a great deal of help, I apprecieate it alot.
It was hard to install this script and get it working cuz I am a big n00b, but you guys have been awesome.
c ya later :yey:
Title: novice.cgi help!!!!
Post by: leighsww on January 05, 2004, 11:25:48 PM
Quote from: SlavicMarket
Yea, I needed to add that line... I dont know how I missed it.


What line (just so we know what the problem was for others in the future)?
Title: novice.cgi help!!!!
Post by: SlavicMarket on January 06, 2004, 03:05:05 PM
The thing that finally solved it, was adding the "sort" variable line in the hidden tags of the form page