×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

2 serious problems

2 serious problems

2 serious problems

(OP)
Help please!!

I have two serious problems with a script I am trying to write.  I am going nuts trying to figure out what's wrong.

I have written a script to take form information and parse it to be sent to an email address.  The script also checks the e-mail address and phone # for validity.  If the input fails the test the HTML code is regenerated with the failed input in red.

Problem #1:
When I test the script the inputted information is not being reentered into the form.  Instead, if you check the source for the newly generated page you see the inputted information in the title bar.  I use the HTML POST method on both scripts.  Here is a sample line:

print "<TR><TD WIDTH=105><B>First Name: </B></TD><TD><INPUT TYPE=\"TEXT\" NAME=\"first\" VALUE=\"$first\" SIZE=40 MAXSIZE=60></TD></TR>\n";


The second problem is that the e-mail checking routine always fails.  Here is the routine (first I replace the ASCII values with the original @ or .):

$email = $formdata{'E-mail'};
$email =~ s/%40/@/g;
$email =~ s/%2/./g;
@check_email = split (//, $email);
foreach $letter (@check_email) {
   if ($letter eq "@") {
       $good_email = 1;
       last;
       }
   else {$good_email=0}
}

if (!$good_email ¦ !$good_phone_number) {
reprint page .....}

Please help!!!  I have almost gone bezerk trying to figure out whatI have done wrong here.

Thanks


 

RE: 2 serious problems

# cgi routines
use CGI_Lite;

# parse the form elements and generate parameters
my $cgi = new CGI_Lite;
my %in = $cgi->parse_form_data;

my $phone = $in{"PHONE"};
my $email = $in{"EMAIL"};

my $good_phone = 0;
my $good_email = 0;

if ($phone =~ /\s*(\()?(\d{3})?\s*(-¦\.¦\))?\s*(\d{3})(\s*)(-¦\.)(\s*)(\d{4})\s*/) {$good_phone = 1;}

if ($email =~ /^([\w\-_\.]+)@(([\w\-_]+)\.)+([\w]+)$/) {$good_email = 1;}

if (!($good_phone && $good_email))
{

  print "Content-type: text/html\n\n";

  print qq~The top of your page~;

  if (!$good_phone)
  {
    print qq~<TR><TD WIDTH="105"><B><font color="#FF0000">Phone: </B></TD><TD><INPUT TYPE="TEXT" style="color:#FF0000;" NAME="PHONE" VALUE="$phone" SIZE="40" MAXSIZE="60"></TD></TR>\n~;
  }
  else
  {
    print qq~<TR><TD WIDTH="105"><B>Phone: </B></TD><TD><INPUT TYPE="TEXT" NAME="PHONE" VALUE="$phone" SIZE="40" MAXSIZE="60"></TD></TR>\n~;
  }

  if (!$good_email)
  {
    print qq~<TR><TD WIDTH="105"><B><font color="#FF0000">Email: </B></TD><TD><INPUT TYPE="TEXT" style="color:#FF0000;" NAME="EMAIL" VALUE="$email" SIZE="40" MAXSIZE="60"></TD></TR>\n~;
  }
  else
  {
    print qq~<TR><TD WIDTH="105"><B>Email: </B></TD><TD><INPUT TYPE="TEXT" NAME="EMAIL" VALUE="$email" SIZE="40" MAXSIZE="60"></TD></TR>\n~;
  }

  print qq~The rest of your page~;
}

Sincerely,

Tom Anderson
CEO, Order amid Chaos, Inc.
http://www.oac-design.com

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close