Results 1 to 7 of 7

Thread: automatic redirect back a page... is it possible?

  1. #1
    no. no, No. NO, NO... NO! stevebakh's Avatar
    Join Date
    Aug 2002
    Posts
    3,228

    automatic redirect back a page... is it possible?

    Hi... well, as the title suggests, I'm looking for some info on whether or not it's possible to redirect back a page using html. For example, if a user fills in a registration form but their entered passwords mismatch, I'd like to be able to to have the error page automagically redirect them back to the reg page with all the entered details still there.

    I guess I could create a "back button", but I think that incorporates js, but is there a way of having the page auto redirect "back" and not just to a url?

    Thanks.

  2. #2
    Cybernetic Interloper ub3r_n00b's Avatar
    Join Date
    Feb 2003
    Location
    Rivendel, East of The Ford of Bruinen
    Posts
    2,086
    Yeah, you can use a Meta tag.

    So

    <meta http-equiv="refresh" content="1,http://www.yourredirecturlhere.com/" />

    this will take you to yourredirecturlhere.com in 1 second....

    This needs to go in the head of the document.

    Just let me know if you have any other questions.

    I guess you can also do this by Javascript, if it is PHP for example just go..

    if ($userenteredpassword == $therightpassword) {
    //do your stuff

    } else {

    $HTML =<<< HTML

    <script type="text/javascript">
    window.location.replace("http://yourreplaceurl.here.com");
    </script>

    HTML;
    print $HTML;

    }


    If that doesnt work you may need to add it onto onload.. so..

    $HTML =<<< HTML

    <script type="text/javascript">
    function redirectIt() {
    window.location.replace("http://yourreplaceurl.here.com");
    }

    window.onload = redirectIt;
    </script>

    HTML;
    print $HTML;



    Hope that helps,

    Preet
    www.erudianart.com

  3. #3
    no. no, No. NO, NO... NO! stevebakh's Avatar
    Join Date
    Aug 2002
    Posts
    3,228
    Yeah, it's a project using perl (with CGI), MySQL and html... so I was hoping I could send the user back to the registration page if, either the username entered already exists, or if the password and verify password inputs mismatch. But I want it to redirect and keep all the previous entries, barr the password/username entries.... if you get what I mean.

  4. #4
    SG Enthusiast
    Join Date
    Jan 2001
    Location
    DC
    Posts
    4,717
    Quote Originally Posted by stevebakh
    Yeah, it's a project using perl (with CGI), MySQL and html... so I was hoping I could send the user back to the registration page if, either the username entered already exists, or if the password and verify password inputs mismatch. But I want it to redirect and keep all the previous entries, barr the password/username entries.... if you get what I mean.
    Redirect the user to the logon page with the form values already entered passed as default values - is the form a GET or POST? POST would be cleaner as the URL wouldn't need to contain all the KV pairs for the form fields already entered.
    anything is possible - nothing is free


    Quote Originally Posted by Blisster
    It *would* be brokeback bay if I in fact went and hung out with Skye and co (did I mention he is teh hotness?)

  5. #5
    Cybernetic Interloper ub3r_n00b's Avatar
    Join Date
    Feb 2003
    Location
    Rivendel, East of The Ford of Bruinen
    Posts
    2,086
    easy, redirect with parameters...

    So if it fails then have it like this..

    http://yourlogindomain.com/loginurl....ilure=password

    then you use $_GET['username'] (in php, no sure what the get is for Perl).

    and then spit out the username into the input field..

    So what I do to check for errors is I get the URL as a string - check for a ? mark.. if it is there then I do a $_GET and get the username and failure or whatever... then act accordingly...

    so

    <meta http-equiv="refresh" content="1,http://yourdomain.com/login.html?username=theusername&failure=usersfailure" />

    Hope that helps.

    Preet
    www.erudianart.com

  6. #6
    Elite Member TonyT's Avatar
    Join Date
    Jan 2000
    Location
    Fairfax, VA
    Posts
    10,336
    Using the full url on a button, a link, or meta refresh will not work, meaning it will not return the user to the previous page where he entered form data. The page will load brand new w/ an empty form. And especially if user has browser set to never use it's cache.

    To return the user to the page where he filled in the form you must call the browser's history object. Example using a button:

    <input type ="button" name ="back" value="Go Back" onclick="history.go(-1)">

    (-2) would send the user back 2 pages, etc., etc..

    However, the best way to do what you want is to use only ONE login page. Why bother with multiple pages for form errors when you can include all and any errors using if-else statements. That way the form values never get lost.
    No one has any right to force data on you
    and command you to believe it or else.
    If it is not true for you, it isn't true.

    LRH

  7. #7
    Junior Member
    Join Date
    Feb 2007
    Posts
    2

    I once had...

    I once had a .html file that redirected the user to his/her last visited page. (or current)

    Letīs say Iīm in www.ThisIsTheSiteImCurrentlyViewing.com and type www.myowndomain.com in the adress-bar then I came back to www.ThisIsTheSiteImCurrentlyViewing.com like I never typed the other url.

    I donīt remember what that html code was but I really want it now.

    Can sombody help me with this?

    Best Regards
    Carl


    Quote Originally Posted by ub3r_n00b View Post
    Yeah, you can use a Meta tag.

    So

    <meta http-equiv="refresh" content="1,http://www.yourredirecturlhere.com/" />

    this will take you to yourredirecturlhere.com in 1 second....

    This needs to go in the head of the document.

    Just let me know if you have any other questions.

    I guess you can also do this by Javascript, if it is PHP for example just go..

    if ($userenteredpassword == $therightpassword) {
    //do your stuff

    } else {

    $HTML =<<< HTML

    <script type="text/javascript">
    window.location.replace("http://yourreplaceurl.here.com");
    </script>

    HTML;
    print $HTML;

    }


    If that doesnt work you may need to add it onto onload.. so..

    $HTML =<<< HTML

    <script type="text/javascript">
    function redirectIt() {
    window.location.replace("http://yourreplaceurl.here.com");
    }

    window.onload = redirectIt;
    </script>

    HTML;
    print $HTML;



    Hope that helps,

    Preet

Similar Threads

  1. Microsoft Windows Malicious Software Removal Tool!
    By fords8 in forum Software Forum
    Replies: 8
    Last Post: 04-06-15, 09:08 AM
  2. Windows Services and Cablenut
    By Bold_Fortune in forum General Broadband Forum
    Replies: 1
    Last Post: 06-07-05, 11:04 AM
  3. ME Help Please
    By momiam2six in forum Software Forum
    Replies: 95
    Last Post: 04-14-03, 06:33 AM
  4. why do i get this page error
    By albertldee in forum General Broadband Forum
    Replies: 4
    Last Post: 01-23-03, 05:28 AM
  5. widows xp system resources
    By kever in forum Software Forum
    Replies: 2
    Last Post: 08-30-02, 05:21 AM

Bookmarks

Posting Permissions

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