Results 1 to 8 of 8

Thread: Stop User from resubmitting form by pressing back button

  1. #1
    Join Date
    Aug 2009

    Stop User from resubmitting form by pressing back button

    I'm making a site that has a form that allows a user to post info to the site, after they have posted they are redirected to a page with the info they just provided but form this page they can press the back button and then get the form again with all the info they filled in. how can i prevent them from just hitting submit again and getting a second copy of this info.

  2. #2
    Join Date
    Jun 2005
    United Kingdom

  3. #3
    Join Date
    Aug 2009
    I dont want to disable the back button I just want to have the page either redirect to something else or clear out the form so that its blank

  4. #4
    Join Date
    Jul 2009
    you should handle that on your server side code. Before you save anything to your database(which Im assuming youre doing so) you should check for repeated content.

    For instance if the user is sending a comment through a form then check that theres no comment under the same user name, with EXACTLY the same text content in the database before you even try to save it. If there's repeated content then just redirect the user to a page telling them that this form has already been submitted.

  5. #5
    Join Date
    Jun 2005
    United Kingdom
    Quote Originally Posted by adamscott421 View Post
    I dont want to disable the back button I just want to have the page either redirect to something else or clear out the form so that its blank
    Did you follow the second link of that Google page? The discussion is relevant.

  6. #6
    Join Date
    Mar 2008
    Or you could redirect to the previous page form after it has been submited and display the form again.

    If you don't what the vistor to be able to resubmit the form on the page which the form was processed after pressing the back. Then that can never happen. The form will have to be submited again.

    You could use JavaScript cookies, saving a cookie of the current time and date the form was submited. So when the user presses the back button you could just check the cookie and compare how previous ago the form was submited then disable the url of the submit button/the action attribute of the form. Perhaps displaying a message "You've already submitted this form in the last 3 minutes. Please wait for ten minutes to submit another"

    You could compare the data in the database with the submited data and the time at which it was submited. Therefore determining whether the content in the database and the submited one is from the same vistor.

    However if you want the user to not be able to resubmit the form at the page where the form was submitted at after pressing the back button/refreshing and be able to see the contents of that page then that can't happen.

  7. #7
    Join Date
    Sep 2008
    Do everything dynamically on the same page... including your "Thank you, this is what you submitted...etc." that is in the page you are redirecting them to. The Back Button will take the to the page before the form and the Refresh Button will present a New Form without data. Easy to do in a php page and also in a html page... just embed the php.
    ...but stupidity is terminal.

  8. #8
    Join Date
    Nov 2002
    Flint, Michigan, USA
    Try someething like this:

    <body ... onload="document.forms[0].reset();">

    Every time this page loads, whether going forward or backward, the form will clear.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.31862 seconds
  • Memory Usage 2,914KB
  • Queries Executed 15 (?)
More Information
Template Usage (33):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (8)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates