SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: function help

  1. #1
    SitePoint Evangelist
    Join Date
    Mar 2005
    Posts
    523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    function help

    Hi GUys, this may be in the wrong section,but please assist ,I posted in the PHP section as well

    I have a PHP function to trap errors, it has a bit of Javascript as well
    as shown below,The idea of the code taken from Kevin's article on sessions.

    Now the problem is that if a field like description is filled and this function come into play, when I am directed back to the orignal form, I loose all the information in the form.

    Is there a way of improving the code so that the $_POST information is still held.

    history.back() takes me to the previous but I loose all the information in the form,Is there a way to maintain that information.


    <?php
    function error($msg) {
    ?>
    <html>
    <head>
    <script language="JavaScript">
    <!--
    alert("<?=$msg?>");
    history.back()
    //-->
    </script>
    <noscript>Your browser does not support Javascript, please enable scripting in your browser.</noscript>
    </head>
    <body>
    </body>
    </html>
    <?
    exit;
    }
    ?>

  2. #2
    CSS & JS/DOM Adept bronze trophy
    Join Date
    Mar 2005
    Location
    USA
    Posts
    5,482
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You would need to post the information to the server and then use the server to send the user back to the page with the fields filled in.
    We miss you, Dan Schulz.
    Learn CSS. | X/HTML Validator | CSS validator
    Dynamic Site Solutions
    Code for Firefox, Chrome, Safari, & Opera, then add fixes for IE, not vice versa.


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
  •