• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Submit Form / POST on page refresh

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author & internet detective
Posts: 42006
911
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
If I had asked people what they wanted, they would have said faster horses - Ford. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic