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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP Script Executing on first visit to page

Status
Not open for further replies.

homeroid

Technical User
Dec 21, 2003
5
GB
Hi all,

I have a html page which consists of form with fields etc.

Once this form is submitted the fields are validated and the information is emailed using asp.

Problem: Even on the first visit to the page before any of the form has been filled the script is executed and email etc is sent out. How can I prevent this form happening ?

Cheers
 
I don't know what you're currently doing but...

I always do something like:
Code:
<%
  if not request.form(&quot;FormVar&quot;) = &quot;&quot; then
  ' do stuff that needs to happen after 
  ' the form is submitted
  
    response.end 
    ' unless you want the form to be available again...
    ' if so just don't use response.end
  end if
%>
Build your form down here.
Just make sure that the form variable that you check for is one that will always be there... Like a hidden form variable... or one that is required by javascript validation.

note:
Some people would recommend that you use two pages for this to keep this kind of confusion from happening. I can see that issue from both sides so I wont tell you to do it one way or the other. I'm just trying to help answer your question.



Travis Hawkins
BeachBum Software
travis@cfm2asp.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top