$form_data = $ENV{'QUERY_STRING'};

$form_data =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C",hex ($1))/eg;

# Replace "+" sign with " "space char.

$form_data =~ s/\+/ /g;

# Split $form_data into name/value pairs:

@fields = split (/&/, $form_data);

# Init variables with form data values from following fields:

# From Text Fields:

# From Text Fields:

($form_name, $candidate) = split (/=/, $fields[0]);

($form_name, $position) = split (/=/, $fields[1]);

# From Radio buttons:

($form_name, $education) = split (/=/, $fields[2]);

($form_name, $status) = split (/=/, $fields[3]);

($form_name, $hired) = split (/=/, $fields[4]);

# From Comments Field:

($form_name, $comments) = split (/=/, $fields[5]);

# Now heres the part where I need some perl wisdom:

# If a user doesn't enter any text for the first HTML field form section 

# for which the variable $candidate is assigned to how would

# I use a If then condition to say if blank then I will

# generate a HTML text error to user indicating field is blank

# until all fields are filled.

open(OUT, ">> dataform.html") or die "Can't open file: $!";

print OUT "CANDIDATE: $candidate\n";

print OUT "POSITION TYPE: $position\n";

print OUT "LEVEL OF EDUCATION: $education\n";

print OUT "STATUS OF AGREEMENT: $status\n";

print OUT "WAS HE OR SHE HIRED?: $hired\n";

print OUT "ANY COMMENTS?: $comments\n\n";

close OUT;

Reply via email to