home *** CD-ROM | disk | FTP | other *** search
/ Teach Yourself CGI Programming with Perl in a Week / CGIPROGRAMMINGPERL.iso / booksrc / 07cgil03.cgi < prev    next >
Encoding:
Text File  |  1995-12-08  |  4.2 KB  |  151 lines

  1. #!/usr/local/bin/perl
  2. push (@INC, "/usr/local/business/http/accn.com/cgi-bin");
  3. require("cgi-lib.pl");
  4. print &PrintHeader;
  5. &ReadParse(*regdata);
  6.  
  7. print<<"EOP" ;
  8. <HTML>
  9. <HEAD><TITLE> Leading Rein confirmation </TITLE>
  10. </HEAD>
  11. <BODY>
  12. EOP
  13.  
  14.     &save_registration_data(regdata);
  15.     &mail_confirmation(regdata);
  16.  
  17. if (length($regdata{"First Name"}) >0 && length($regdata{"Last Name"}) >0 )
  18. {
  19. print <<"EOP" ;
  20. <h3>
  21. Thank you $regdata{"First Name"} $regdata{"Last Name"} for registering with 
  22. the Leading Rein.</h3>  Please verify the following information and make
  23. any corrections necessary.
  24. EOP
  25.     $registration_type="Confirm Registration Data";
  26.     print "<ul>";
  27. foreach $var (keys (%regdata) )
  28.    {
  29.    if (length($regdata{"$var"})== 0)
  30.       {
  31.       print "<li>Your <em> $var </em> will be used to help confirm your order please fill in the <em> $var </em> field" ; 
  32.       }
  33.    }
  34. print "</ul>";
  35.  
  36. }
  37. else
  38.    {
  39.        $registration_type="Submit Registration";
  40.    }
  41. if (defined ($regdata{"Phone Number"} ))
  42.    {
  43.    $PhoneNumber = $regdata{"Phone Number"} ;
  44.    }
  45. else
  46.    {
  47.    $PhoneNumber ="(999) 999-9999";
  48.    }
  49.  
  50.  
  51. print <<"TEST" ;
  52. <hr noshade>
  53. <center>
  54. <FORM Method=POST Action="/cgibook/chap7/reg4.cgi">
  55. <!-- FORM Method=GET Action="/cgi-bin/env.cgi" -->
  56. <input type=hidden name=SavedName value="$regdata{'First Name'} $regdata{'Last Name'}">
  57. <table border = 0 width=60%>
  58. <caption align = top> <H3>Leading Rein Registration Form </H3></caption>
  59. <th ALIGN=LEFT> First Name
  60. <th ALIGN=LEFT colspan=2 > Last Name <tr>
  61.  
  62. <td>
  63. <input type=text size=10 maxlength=20 
  64. name="First Name" value=$regdata{"First Name"} >
  65. <td colspan=2>
  66. <input type=text size=32 maxlength=40 
  67. name="Last Name" value=$regdata{"Last Name"} > <tr>
  68. <th ALIGN=LEFT colspan=3>
  69. Street Address <td> <td> <tr>
  70.  
  71.  
  72. <td colspan=3>
  73. <input type=text size=61 maxlength=61 
  74. name="Street" value="$regdata{'Street'}" > <tr>
  75. <th ALIGN=LEFT > City
  76. <th ALIGN=LEFT > State
  77. <th ALIGN=LEFT > Zip <tr>
  78. <td> <input type=text size=20 maxlength=30 
  79. name="City" value="$regdata{'City'}" >
  80. <td> <input type=text size=20 maxlength=20 
  81. name="State" value="$regdata{'State'}" >
  82. <td> <input type=text size=5 maxlength=10 
  83. name="zip" value="$regdata{'zip'}" > <tr>
  84.  
  85. <th ALIGN=LEFT  colspan=1> Phone Number 
  86. <th ALIGN=LEFT  colspan=2> Email Address <tr>
  87. <td colspan=1> <input type=text size=15 maxlength=15 
  88. name="Phone Number" value="$PhoneNumber "> 
  89. <td colspan=2> <input type=text size=32 maxlength=32
  90. name="Email Address" value=$regdata{"Email Address"} ><tr>
  91. <td width=50%> <input type="submit" name="simple" value=" $registration_type " >
  92. <td width=50%> <input type=reset> <tr>
  93.  
  94. </table>
  95. </FORM>
  96. </center>
  97. <hr noshade>
  98. </body>
  99. </html>
  100. TEST
  101.  
  102. sub save_registration_data  {
  103.     local($regdata) = @_;
  104.    if ($regdata{'simple'} eq " Confirm Registration Data ")
  105.       {
  106.       open (RegDataFile, 
  107.             '>>/usr/local/business/http/accn.com/cgibook/chap7/rdf')
  108.       || die "cant open reg data file\n";
  109.  
  110.       foreach $var (keys (%regdata) )
  111.         {
  112.         print (RegDataFile "$var = $regdata{\"$var\"}:");
  113. #        print "$var $regdata{$var}:";
  114.         }
  115. #      print (RegDataFile "\n");
  116.       print "<br>";
  117.  
  118.   }
  119. }
  120.  
  121. 01: sub mail_confirmation{
  122. 02:     local($regdata) = @_;
  123. 03:     $temp = "Thank you $regdata{'First Name'} $regdata{'Last Name'} for registering with the Leading Rein.\n";
  124. 04:     if ($regdata{'simple'} eq " Confirm Registration Data ")
  125. 05:        {
  126. 06:        if ($regdata{'Email Address'} =~ /[;><&\*`\|]/ ){
  127. 07:           print "<hr><h3> The email address you submitted is malformed.</h3> $regdata{'Email Address'}<hr> ";
  128. 08:           } 
  129. 09:        else {
  130.  
  131. 10:        open (MAIL, "|mail $regdata{'Email Address'}")
  132. 11:           || die "cant mail program\n";
  133. 12:            print MAIL <<EOM;
  134. 13:            $temp
  135. 14:       Please verify the following information.
  136.  
  137. 15:            Your name is and mailing address are:
  138. 16:            $regdata{'First Name'} $regdata{'Last Name'}
  139. 17:            $regdata{'Street'}
  140. 18:            $regdata{'City'}, $regdata{'State'}  $regdata{'zip'}
  141.  
  142. 19:            Your phone number is $regdata{'Phone Number'}
  143. 20: EOM
  144. 21:           }     
  145. 22:       }
  146. 23:    }
  147.  
  148.       
  149.  
  150.  
  151.