<%@ LANGUAGE = PerlScript %> <% $requestMethod = $Request->ServerVariables('REQUEST_METHOD')->Item; $product_code = &f_getClientVariable('p_code', ''); $product_title = &f_getClientVariable('p_title', ''); $message = &f_getClientVariable('message', 'Not Provided'); $visitor_name = &f_getClientVariable('visitor_name', 'Not Provided'); $telephone_no = &f_getClientVariable('telephone_no','Not Provided'); $email = &f_getClientVariable('email','Not Provided'); $address = &f_getClientVariable('address','Not Provided'); $action = &f_getClientVariable('action',''); if ( $action eq '' ){ $title = "Kimtee Jewellers - Product Order Form" ; $form = &f_readFile($Server->MapPath("product-order-form.txt")); $form =~ s///; $form =~ s///; $form =~ s///; $form =~ s///; $form =~ s///; $form =~ s///; $form =~ s///; $form =~ s///; $content = &f_readFile($Server->MapPath("template.html")); $content =~ s//$form/; $content =~ s//$title/; $Response->write($content); return; } $found = 0; @dbProductCode = &f_readFileIntoArray($Server->MapPath("product-code.txt")); $found = grep(/^$product_code$/i,@dbProductCode); if ($found == 0 ){ $error = "Product Code is incorrect. Please check."; $form = &f_readFile($Server->MapPath("product-order-form.txt")); $form =~ s//$error/; $form =~ s//$product_code/; $form =~ s//$product_title/; $form =~ s//$message/; $form =~ s//$visitor_name/; $form =~ s//$telephone_no/; $form =~ s//$email/; $form =~ s//$address/; $form =~ s/Not Provided//g; $content = &f_readFile($Server->MapPath("template.html")); $content =~ s//$form/; $content =~ s//$title/; $Response->write($content); return; } &f_send(); $thanks = <Product Order Form

Your order has been sent successfully.We will come back to you as soon as possible.

Thank you.

TX1 $title = "Kimtee Jewellers - Product Order Form" ; $content = &f_readFile($Server->MapPath("template.html")); $content =~ s//$thanks/; $content =~ s//$title/; $Response->write($content); sub f_send { my $body = <Product Code:$product_code
Product Title:$product_title
Visitor Name: $visitor_name
Visitor Phone : $telephone_no
Email: $email
Address : $address
Message : $message
### end of message ### BODY11 &f_sendEmail( "Website Visitor", "mayor\@HamaraShehar.com", "info\@kimteejewellers.com", "Order from your website visitor", $body ); #$Response->write($body); } sub f_readFile { local( $fileName ) = shift; local( $tempContent ); open( FL2, "<$fileName" ); @tempContent = ; close( FL2 ); return ( join( '', @tempContent ) ); } sub f_getClientVariable { my $var1 = shift; my $default1 = shift; my $temp1 = ''; if ( $var1 eq null ) { return 'null'; } if ( defined($Request->Form($var1)->Item) ) { $temp1 = $Request->Form($var1)->Item; } if ( $temp1 ne '' ) { return $temp1; } elsif ( defined($default1)) { return $default1; } return 'null'; } ##f_getClientVariable sub f_readFileIntoArray { my $fileName = shift; my @lines; open( FL1, "<$fileName" ); @lines = ; close( FL1 ); return ( @lines ); } sub f_sendEmail { my $fromWhom = shift; my $fromEmail = shift; my $toEmail = shift; my $subject = shift; my $body = shift; my $Mailer = $Server->CreateObject("SMTPsvg.Mailer"); $fromWhom = 'From HamaraShehar' if ($fromWhom eq ''); $fromEmail = 'mayor@hamarashehar.com' if ($fromEmail eq ''); $objMail = $Server->CreateObject("CDONTS.Newmail"); $objMail->{'To'} = $toEmail; $objMail->{'Subject'} = $subject; $objMail->{'From'} = $fromEmail; $objMail->{'Body'} = $body; $rc = $objMail->send(); undef $objMail; return 1; } %>