CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
form data

 



jacksonpt
Deleted

Apr 7, 2000, 9:36 AM

Post #1 of 6 (907 views)
form data Can't Post

I have put 2 perl scripts up intended to capture HTML form information. Sometimes the data is captured, and e-mailed to me correctly, sometimes it is not... and I can't figure out why. It seems like there are times when the data is not being captured at all (since I receive a blank e-mail). Does this sound like anything to you?

I could really use some help with this one.
Thanks,
Jackson

PS - my e-mail is jtaylor@binghamton.edu if you think this might get fairly involved. Thanks again.


darian
Deleted

Apr 7, 2000, 2:14 PM

Post #2 of 6 (907 views)
Re: form data [In reply to] Can't Post

Are you checking to see if the user has entered any information? You can check a couple of ways. The first is using javascript. The second is to test each field as it is sent to the script.

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

if($field1 eq "") { print "You need to fill in this field."; }</pre><HR></BLOCKQUOTE>

Post your code so we can go through it and check.


jacksonpt
Deleted

Apr 12, 2000, 5:13 AM

Post #3 of 6 (907 views)
Re: form data [In reply to] Can't Post

Thanks Darian. I work for a state university and it never occured to me that people may be submitting blank forms. I threw in some javascript to prevent them from doing so, and it seems to have helped.

If I run into any more problems, I will post the code. Thanks again.

-Jackson


Jasmine
Administrator

Apr 12, 2000, 7:53 AM

Post #4 of 6 (907 views)
Re: form data [In reply to] Can't Post

What I do to prevent someone from entering a field full of spaces (which would make $field1 eq "" false is):

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


($temp = $field1) =~ s/ //g;
unless($temp){print "You need to fill in this field}
</pre><HR></BLOCKQUOTE>

But even this doesn't help if they filled out a zero, and a zero is a valid entry. So, the best way to check if anything at all is entered in the field is to see if it's defined.

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


($temp = $field1) =~ s/ //g;
unless(defined($temp)){print "You need to fill in this field}
</pre><HR></BLOCKQUOTE>

The above does not alter the value of $field1 and it allows a value of 0 to be entered.


japhy
Enthusiast

Apr 12, 2000, 8:00 AM

Post #5 of 6 (907 views)
Re: form data [In reply to] Can't Post

I suggest you use:

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


if ($input =~ /\S/) {
# input has a non-whitespace character in it
}
</pre><HR></BLOCKQUOTE>

Jasmine, just because $temp1 is empty (because it contained all spaces), doesn't make it undef. You'd want to test against the empty string "". But I find the method above to be better and faster.

[This message has been edited by japhy (edited 04-12-2000).]


Jasmine
Administrator

Apr 12, 2000, 2:54 PM

Post #6 of 6 (907 views)
Re: form data [In reply to] Can't Post

I stand instructed... thank you Smile

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives