Email Form Sends Only Once

email form sends only once

Page 1 of 1

1 Replies - 3764 Views - Last Post: 29 May 2003 - 07:01 AM Rate Topic: -----

#1 poab  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 26-June 02

Email Form Sends Only Once

Posted 29 May 2003 - 06:21 AM

Hi :)

I'm just getting into asp and I have a small problem. I tried to search but I wasn't sure what to search for so sorry if this has already been answered.

I have a REALLY basic form. When the form is submitted it calles the same asp page. The beginning of the page uses:
<% If Request.ServerVariables("CONTENT_LENGTH") <> 0 Then
In order to check if the form has been submitted or not. If it has the page sends an email with the form's details.

Trouble is if someone presses 'refresh' then the form sends another email. I was wondering if there was any way to wipe the "CONTENT_LENGTH" after the email sending, so if they refresh the page it would just be like they had just accessed the page for the first time.

I need to get this sorted because I want to put in some form validation. I want to submit the form, check validation, and if that is ok then send the email. If not, an email shouldn't be sent.

Can anyone help me?

cheers.

Is This A Good Question/Topic? 0
  • +

Replies To: Email Form Sends Only Once

#2 klewlis  Icon User is offline

  • cur tu me vexas?

Reputation: 8
  • View blog
  • Posts: 1,723
  • Joined: 09-November 01

Re: Email Form Sends Only Once

Posted 29 May 2003 - 07:01 AM

A couple of things:

To check whether the form has been submitted, I usually look for the submit button instead. So, for example, if my submit button is:
<input type="submit" name="submit" value="Send">

Then my statement will say:
If Request.Form("submit") = "Send" Then

It's pretty reliable.

You can't prevent the form from sending twice if the person refreshes the page, because that is a browser thing. However, you could set a session variable the first time, and then check for it the second time. If it exists, then don't send the email.... make sense?

Another option is to redirect them after sending the email. Then refreshing would be ok.... you could even redirect them back to the same form page, but it would be like a new page.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1