SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Why does this not work? Using Wamp5 installation

    The code below is giving me grief. If I redirect index.php back to itself in the form event, and of course put the variables into place - $Fname = $_POST['TFN']; then it returns with the value still in my input box. However if I send it to another form and back with process.php, my variable $Fname is empty.
    I tried adding a line to prevent issue of Race being established, but it made no difference. I still think I have a configuration problem of php, unless there is a real issue as to why this fails. Appreciate any help. Thanks

    index.php
    <?
    session_start;
    echo $Fname;
    ?>

    <html><body>
    <form action="process.php" method="post">
    <input type="Text" name="TFN" value="<?echo $Fname; ?>">

    <input type="submit" />
    </form>
    </body></html>


    FORM process.php
    <?
    session_start;
    $Fname = $_POST['TFN'];
    echo $Fname;
    ?>

    <html><body>
    </body>
    <a href="index.php">back</a><p>
    </html>

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Clicking the 'Back' link puts the browser at index.php. There was no POSTed form so there is no data in $_POST. That's not a configuration problem -- that's just not writing the code to do what you want

    PHP Code:
    <a href="index.php?Fname=<?php echo $_POST['TFN']; ?>">back</a>
    That would make $_GET['Fname'] available on index.php.

    Off Topic:

    Why do you keep writing "session_start;"? session_start() is a function (note the parentheses), but you never do anything with the session.

  3. #3
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Dan,
    I tried your code in the return button, and I see the Fname value appear in the browser address. I don't know how to get that and put it back in the textbox. Basically I have been stuck with this problem for 2 weeks. All I want is an input box to retain anything that was entered in it, to be there when going back to the page again. Many thanks again

  4. #4
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Still struggling to find where variables go missin

    Reviewed look at problem

    This page allows 1 input box to be entered with data. On submission it goes to process.php which
    will do other things, but at the moment it reverts back to this page (index.php) I want it to come back with
    the data still in the textbox (as though it was recalled for review/editing/change)
    As you see when it does come back, nothing gets echoed back, even if I allow $Fname = $_SESSION['HLD']; to
    be remmed out. All data in the second form arrives there all okay, it gets lost comming back.

    Page index.php
    <?
    session_start();
    // $Fname = $_SESSION['HLD'];
    echo $Fname;
    echo $_SESSION['HLD'];
    // NOTHING EVER GETS ECHOED ABOVE?????

    ?>

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>New Page 1</title>
    </head>

    <body>

    <form method="POST" action="process.php" method="post">

    <p>&nbsp;</p>
    <p><input type="Text" value="<?echo $Fname; ?>" name="TFN"><input type="submit" value="Submit" ></p>

    </form>

    </body>


    Page Process.php
    <?
    session_start();
    // put posted TFN into $Fname
    $Fname = $_POST['TFN'];
    echo $Fname;
    // $Fname gets echoed okay
    // Put $Fname into session variable
    $_SESSION['HLD'] = $Fname;
    echo $_SESSION['HLD'];
    // $_SESSION['HLD'] gets echoed okay
    ?>

    <html><body>
    </body>
    <a href="index.php">back</a><p>
    </html>

    Any ideas, thanks

  5. #5
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Are index.php and process.php on the same domain?

  6. #6
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, yes they are in the same domain - localhost. Regards

  7. #7
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    All my problems have gone away after 3 weeks. Got rid of Wamp5 installation and downloaded XAMPP. Everything works fine. Could be a configuration problem, who knows, problems gone. Thanks


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
  •