Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Empty Forms Submitted 1

Status
Not open for further replies.

kelly5518

Technical User
Aug 1, 2005
72
US
Hi,

I have a problem with a form on a site. This is a guestbook script that was modified for my needs. The form posts information to a list that's displayed on the site. The problem is that I'm getting empty posts on the site. I have both client side and some server side validation, but only if the script is generated by the form on the site.

I've come to the conclusion that someone is just activating the script by typing the url in the browser, which is then creating empty posts on the web page (except for the date which is generated by the script itself, not the form.)

Can anyone tell me how I can prevent simply typing the script's url in the browser from activating the script.

Thanks...
 
make sure all form fields that your script uses are filled in (and filled in correctly) using server side validation. If you only check the the fields contain something/anything, a peson can enter all spaces, which looks blank to the eye but not to perl. So make sure form fields contain a minimum of valid characters. If there are not, then don't allow he script to write anything to the file.
 
The problem is that the form is where the fields that are "required" are specified, so if someone just enters the url in the browser, then the script is executed without any "required" fields.

You could hard-code the script itself to check for the specific fields, except that I don't know perl. :-\

I thought maybe there was a simple way to make sure that it was only executed through a "post". Anyone know if that's possible?
 
The simple way would be to check one of your required variables, and if it's empty, generate an error message and represent the form

HTH
--Paul

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
You could hard-code the script itself to check for the specific fields, except that I don't know perl. :-\

Well, that's what these forums are for.

I thought maybe there was a simple way to make sure that it was only executed through a "post". Anyone know if that's possible?

there is actually:

Code:
unless ( uc($ENV{'REQUEST_METHOD'}) eq 'POST') {
 print error message or whatever
}

that might help with your problem.
 
This should do the trick.

Thanks a bunch!

kelly

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top