Loading ...
Sorry, an error occurred while loading the content.

New to discussion group, need help with CGI

Expand Messages
  • tito7724
    Hello! I am learning CGI and I was wondering if anyone can help me. the website is: http://www.traysl.netfirms.com/africa4.htm Iam trying to get my form to
    Message 1 of 1 , Nov 23, 2002
    • 0 Attachment
      Hello! I am learning CGI and I was wondering if anyone can help me.

      the website is: http://www.traysl.netfirms.com/africa4.htm


      Iam trying to get my form to work.

      I cannot get it working as in when the person fills out the form,
      they will not get a confirmation email sent to the address I typed
      in. Also I do not get a confirmation email (telling me that some one
      has filled out the form).

      Also how do you get it so that the fields (name, street address etc.)
      require text before the person who fills out the form submits it.

      I have attache my script:
      #!usr/bin/perl
      #run subroutine to turn stdin into an array named %in
      require "cgi-lib.pl";
      &ReadParse;
      #store location of mail program in variable
      $mailprog = '/usr/lib/sendmail';
      print &PrintHeader;
      unless (-e $mailprog)
      {
      print <<"PrintTag";
      <HTML><BODY>
      <H3>Cannot find $mailprog.</H3>
      <P>There is a typo in the mail program path.</P>
      </BODY></HTML>
      PrintTag
      exit (0);
      }

      #create confrimation web page
      print <<"PrintTag";
      <HTML><HEAD>
      <TITLE> Thanks for responding!</TITLE>
      </HEAD>
      <BODY BGCOLOR="black" TEXT="33FFCC">
      <H2>Thank You!</H2>
      <P>Thank You for Entering Afnan's Contest</P>
      <P>Check your e-mail for a message from us.</P>
      <!-- change the URL below to YOUR home page-->
      <a href="http://www.traysl.netfirms.com/africa4.htm">Home</a>
      </body></html>
      PrintTag

      #open mail program
      open (MAIL, "|$mailprog -t") ||
      die "Can't open mail program\n";

      #print message headers (to, from, subject, etc)
      print MAIL "To: $in{'email'}\n";
      print MAIL "Reply-To: $in{'empmail'}\n";
      print MAIL "From: $in{'empmail'}\n";
      print MAIL "Subject: Afnan's Contest.\n\n";

      #print body of message
      print MAIL "Dear $in{'custname'}:\n\n";
      print MAIL "Thank you for entering my contest. This e-mail ";
      print MAIL "confirms that we have received your ";
      print MAIL "entry. If you are the winner of two free tickets, ";
      print MAIL "of my Safari Tour, you will be notified by email ";
      print MAIL "on January 3, 2003 ";
      print MAIL "Sincerely yours,\n\n";
      print MAIL "Afnan\n";
      print MAIL "Afnan's Boswania Safari\n";

      #close mail program, releasing message to be sent
      close(MAIL);

      #open mail program from a second message to employee
      OPEN (MAIL, "|$mailprog -t") || die "Can't open mail program\n";

      #print message headers
      print MAIL "To: $in{'empmail'}\n";
      print MAIL "Reply-To: $in{'email'}\n";
      print MAIL "From: $in{'email'}\n";
      print MAIL "Subject: Catalog Order.\n\n";

      #create body of message
      print MAIL <<"PrintTag";
      New Contestent:

      $in{'custname'}
      $in{'street'}
      $in{'city'} $in{'state'} $in{'zip'}
      $in{'country'}

      $in{'comments'}
      PrintTag
      if (($in{'name'} eq "") ||
      ($in{'email'} eq "") ||
      ($in{'comments'} eq ""))
      {
      print <<"PrintTag";
      <html><body>
      <h2>Data Incomplete</h2>
      <p>Your request to send comments to Afnan has been
      rejected due to insufficient information. To
      properly send your comments, please fill out:</p>
      <ul>
      PrintTag
      if ($in{'name'} eq "")
      {
      print "\n<li> Your Name\n";
      }
      if ($in{'email'} eq "")
      {
      print "\n<li> Your Email Address\n";
      }
      if ($in{'comments'} eq "")
      {
      print "\n<li> Your comments\n";
      }
      print "</ul>\n</body>\n</html>\n";
      exit(0);
      }

      if (($in{'comments'} =~ /dang/) ||
      ($in{'comments'} =~ /consarn/) ||
      ($in{'comments'} =~ /friggin/) ||
      ($in{'comments'} =~ /dagnabit/) ||
      ($in{'comments'} =~ /blasted/))
      {
      print<<"PrintTag";
      <html><body>
      <h2>Request denied-improper language.</h2>
      </body></html>
      PrintTag
      exit(0);
      }

      $in{'name'} =~ s/\</</g;
      $in{'name'} =~ s/\>/>/g;
      $in{'email'} =~ s/\</</g;
      $in{'email'} =~ s/\>/>/g;
      $in{'comments'} =~ s/\</</g;
      $in{'comments'} =~ s/\>/>/g;

      #close mail programs and send message
      close (MAIL);

      #end of program



      I hope someone can help me. I am new to learning CGI/Perl.

      I would really appreciate it.

      Thanks
    Your message has been successfully submitted and would be delivered to recipients shortly.