Kind Sirs, Im having a bit of trouble with my email form. My conditional statement does not return true when you click on Send. I have been working on this simple script for a couple days and I cant seem to figure out whey it will not read the send as an action. Any Ideas would be greatful.
Kind Regards, Daniel J. Rychlik
> #!/usr/bin/perl -w > > # Email Processing form written by Daniel J. Rychlik > [EMAIL PROTECTED] > # This script was rewritten from previous version, because I like keeping > # everything nice an tiddy. 03.02.03 > > # Lets load all of the correct modules > use strict; > use CGI qw/ :standard escapeHTML;
> # Check the action.
> my $action = param('action');
>
> if ('action' =~ /^send/i) {
> send_mail();
> }
> else {
> print_form();
> }
>
>
> # Use the Bit shift to get STDOUT the output from our script.
> # Remember to tell the browser what your sending.
>
> sub print_form() { # Open Subroutine.
>
> print "Content-type: text/html\n\n";
>
> # Bit Shift->Insert HTML here.
>
> print <<START;
>
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
> <title>:::: TCS Form ::::</title>
> </head>
>
> <body bgcolor="#FFFFFF" text="#000000" bgproperties="fixed">
> <form name="testhtml.pl" method="post"
> action="http://localhost/perl/testhtml.pl">
> <table width="600" border="1" align="center" bordercolor="#0099FF">
> <tr align="left" valign="middle">
> <td width="193" height="50%">
> <div align="left"><font size="2"><i><b><font face="Arial,
> Helvetica, sans-serif">Your
> Name*</font></b></i></font></div>
> </td>
>
> <td width="435">
> <div align="left"><font size="2">
> <input type="text" name="name">
> </font></div>
> </td>
> </tr>
> <tr align="left" valign="middle">
> <td width="193" height="50%">
> <div align="left"><font face="Arial, Helvetica, sans-serif"
> size="2"><b><i>Your
> Company* </i></b></font></div>
> </td>
>
> <td width="435">
> <div align="left"><font size="2">
> <input type="text" name="cmpy">
> </font></div>
> </td>
> </tr>
> <tr align="left" valign="middle">
> <td width="193" height="50%">
> <div align="left"><font face="Arial, Helvetica, sans-serif"
> size="2"><b><i>Email
> Address* </i></b></font></div>
> </td>
>
> <td width="435">
> <div align="left"><font size="2">
> <input type="text" name="email">
> </font></div>
> </td>
> </tr>
> <tr align="left" valign="middle">
> <td width="193" height="50%">
> <div align="left"><font face="Arial, Helvetica, sans-serif"
> size="2"><b><i>Phone
> Number </i></b></font></div>
> </td>
>
> <td width="435" height="39">
> <div align="left"><font size="2">
> <input type="text" name="phone">
> </font></div>
> </td>
> </tr>
> <tr align="left" valign="middle">
> <td width="193" height="50%">
> <div align="left"><font face="Arial, Helvetica, sans-serif"
> size="2"><b><i>Requested
> Information </i></b></font></div>
> </td>
>
> <td width="435" height="41">
> <div align="left"><font size="2">
> <select name="menuopt" size="1" multiple>
> <option>Mobile Computing Solutions</option>
> <option>Cell Phone</option>
> <option>Web Hosting</option>
> <option>Sales</option>
> <option>Network Communications</option>
>
> </select>
> </font></div>
> </td>
> </tr>
> <tr>
> <td width="193" height="2">
> <div align="left"><font face="Arial, Helvetica, sans-serif"
> size="2"><b><i>Your
> Notes* </i></b></font></div>
> </td>
> <td width="435" height="2">
> <textarea name="notes" cols="50" rows="15"></textarea>
>
> </td>
> </tr>
> <tr>
> <td colspan="2" height="2" width="626">
> <div align="left"><font face="Arial, Helvetica,
> sans-serif"><font face="Arial, Helvetica,
> sans-serif"><b><i></i></b></font></font></div>
> <div align="center"><font face="Arial, Helvetica,
> sans-serif"><font face="Arial, Helvetica, sans-serif"><b><i>
> <input type="submit" name="Submit" value="Send Now">
> <input type="reset" name="reset" value="Clear">
> </i></b></font></font></div>
> </td>
>
> </tr>
> </table>
> </form>
> </body>
> </html>
>
> START
>
>
> } #End Subroutine
>
> # Lets check everything, process the text that was inputted and send it.
>
> sub send_mail {
>
> my $time = localtime;
> my $name = param('name');
> my $email = param('email');
> my $cmpy = param('cmpy');
> my $notes = param('notes');
> my $phone = param('phone');
> my $menuopt = param('menuopt');
> my $host = remote_host;
>
> # Lets check to see if something was entered in the required fields.
> # If nothing entered, pass it off the print error sub routine.
>
> if ($name eq '' or $name =~ /^\s+$/) {
> print_error('');
> }
> if ($email eq '' or $email =~ /^\s+$/) {
> print_error('');
> }
> if ($cmpy eq '' or $cmpy =~ /^\s+$/) {
> print_error('');
> }
> if ($notes eq '' or $notes =~ /^\s+$/) {
> print_error('');
> }
>
> # Ok, lets strip any white space from our fields.
>
> $name =~ s/^\s+//;
> $name =~ s/\s+$//;
> $email =~ s/^\s+//;
> $email =~ s/\s+$//;
> $cmpy =~ s/^\s+//;
> $cmpy =~ s/\s+$//;
> $notes =~ s/^\s+//;
> $notes =~ s/\s+$//;
> $phone =~ s/^\s+//;
> $phone =~ s/\s+$//;
>
> # Lets deal with HTML in our fields. Just in case ;)
>
> $name = escapeHTML($name);
> $email = escapeHTML($email);
> $cmpy = escapeHTML($cmpy);
> $notes = escapeHTML($notes);
> $phone = escapeHTML($phone);
>
> # Lets deal with line breaks from the notes field.
>
> $notes =~ s/(?:\015\012?|\012)</BR>/g;
>
> # I took out my SMTP stuff, because Im using my Vaio w/mandrake to
> get my action to work.
> sucess(); # Bounce to sucess sub routine. > > } # End Mail subroutine > > # If everything is success, then let the user know.
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]