29 users online (1 members and 28 guests)  


  Results 1 to 4 of 4

Related

  1. submission form help    Forum: Website Scripts Forum
    Replies: 1
  2. form submission    Forum: Website Scripts Forum
    Replies: 2
  3. Form Submission    Forum: Website Scripts Forum
    Replies: 2
  4. form submission    Forum: HTML Forum
    Replies: 6
  1. #1
    joharran's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2009
    Posts
    2

    Redirection after form submission

    I'm using perl to validate a form and save the results. That part works fine. Here's a scenario to demonstrate my issue:

    Page #1 contains a link to page #2. Page #2 contains a form which runs my script upon submission.

    If the data doesn't validate, I would like to reload page #2 with an error message. (I can handle adding the message, I just need a way to trigger the page reload)

    If the data does validate, I would like to force the browser to backup and display page #1. I do not wish to add a new iteration of page #1 after page #2, I want to go back to the previous page.

    I considered using javascript to submit the form, but I cannot figure out a way to inform javascript whether the validation passed/failed.

    Does anybody have any suggestions?

  2. #2
    jthayne's Avatar

    Status
    Offline
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    508

    Re: Redirection after form submission

    Here you go:

    Code:
    print "Location: http://newdomain.com/newfile.pl\n\n";
    Found here

  3. #3
    joharran's Avatar
    New User

    Status
    Offline
    Join Date
    Mar 2009
    Posts
    2

    Re: Redirection after form submission

    Thanks for your reply, but this doesn't give me the result that I am looking for. This will add a new copy of page 1 after page 2 in the browser history. I need to display the copy of page 1 which is before page 2, similar to executing history.go(-1) from javascript.

    What I am looking for is either a way to execute this (history.go(-1)) directly from perl, or a way to tell javascript whether the form validation passed or failed.

  4. #4
    jthayne's Avatar

    Status
    Offline
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    508

    Re: Redirection after form submission

    That is actually the way most places do it, but to answer your question, perl is not capable of accessing the browser history by itself as it is run on the server, and the browser history is on the client. You will need to serve up a page similar to the following.

    Code:
    <html>
    <head>
    <script type="text/javascript">
    history.go(-1)
    </script>
    </head>
    </html>
    The problem with doing it this way, is that you cannot pass any variables backwards, and therefore, can't display a message that the validation passed or failed. Are your web pages all HTML, or are you using any scripting language other than the validating cgi mentioned?



Tags for this Thread