• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Submit Form / POST on page refresh

 
Sam Gardner
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Guys -

I have a timed page that I need to use to submit a form upon the end of a specified time period.

The usage would be: User visits page, 90 seconds later all form data is submitted and user is redirected to next page.

The user is well aware that the page they are on is timed (its for a web-only experiment), so I'm not too worried about "unfriendly" browser behavior on this page.

Ideally, I'd like to avoid using JavaScript (some of our targeted users are using no-script for various reasons, but if its the only way, so be it), and would also like to avoid just passing variables through the URL (to cut down on the possibility of spoofing). It is easy enough to set a META refresh tag to do the redirecting, but at the end of the time period I need some way for the response header to be set as if the submit button was clicked, whether or not it actually was.

Thanks in advance for any thoughts you might have.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34669
366
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sam,
I think you have to use JavaScript for this.

As far as the URL, you could use a POST to pass parameters. But that can be spoofed too. You really can't trust anything from the client absolutely.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well there is no way to submit the form other than the user clicking a button or calling it with JavaScript.

SO

setTimeout
and
document.formName.submit()

will be your friend

Eric
 
Andy Crane
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Eric. Well, agree may not be correct, as in, he's right, you're not going to submit that form unless you use javascript.

He's got the correct way to think about it as well. You're not refreshing the page on timeout, you're submitting the form on timeout.

You can provide a message for the noscript users letting them know that the page will not refresh and that they will need to click submit in order to submit the form.

The other users won't be impacted at all this way.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic