SitePoint Sponsor

User Tag List

Results 1 to 1 of 1
  1. #1
    Web Enthusiast
    Join Date
    Jul 2000
    Location
    Western Massachusetts, USA
    Posts
    1,389
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    register globasl off and back from form alert

    Trying to get a viewer back to a form with info partly filled in after an alert message using the JavaScript history.back() method. However, I suspect that because I have register_globals set to off, I'll need to do it using PHP.

    Here's the background

    On one site, going back to a form with info partly filled in is easily done using Kevin's "common.php" include.

    PHP Code:
     <?php // common.php
    function error($msg) {
        
    ?>
        <html>
        <head>
        <script language="JavaScript">
        <!--
            alert("<?php echo $msg?>");
            history.back();
        //-->
        </script>
        </head>
        <body>
        </body>
        </html>
        <?php
        
    exit;
    }
    ?>
    Works fine for me at:
    http://www.clickbasics.com/catalog.php

    However,
    Code:
    history.back();
    does not work at:
    http://test.kripalu.org/ctlg_order.php
    where I have written:
    PHP Code:
     //check that the user has entered the same email address twice 
    if ( ($_POST["email_address"]) != ($_POST["email_address_verify"]) ) {
    ?>
    <script language="JavaScript">
    <!--
    alert("The two e-mail addresses you just entered don't match. Please try again.");
    //document.location.href="<?//echo($_SERVER["HTTP_REFERER"]); ?>";
    //history.go(-1);
    history.back();
    // -->
    </script>
    This second site has register_globals set to off in the .htaccess script
    Code:
    php_value register_globals 0
    Am I right that this is the problem? If so, how do I get the data back into the form using PHP when the user clicks OK on the error message?
    I tried adding

    PHP Code:
    $ctlg_firstname $_POST["firstname"]; 
    etc. to the form, so the info is available when going back, but this didn't work.

    I suspect I need to load the form anew with the information the user has already enterd, but not sure how to do it in PHP.

    I have attached the second script for reference.
    Attached Files Attached Files
    Paul C.
    ClickBasics
    http://www.clickbasics.com


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
  •