Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is causing this please - 1

Status
Not open for further replies.

ZOR

Technical User
Jan 30, 2002
2,963
GB
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>
 
From where are you expecting $Fname to come? You're not setting a session variable. Nor are you later referencing it.

It looks like you've run into the register_globals problem I describe in section 1.1 of my faq: faq434-2999



Want the best answers? Ask the best questions! TANSTAAFL!
 
Thanks. My thinking was the first time the index page was opened, $Fname would be empty. When the form was submitted to precess.php, it would get filled by $Fname = $_POST['TFN'];
and on returning to the index page would show something there. I have tried replacing $Fname with $_SESSION['TFN'] but that still did not work. Sorry yes, did start a new thread as thought it would be a clean in/out answer of you cannot do that. Regards
 

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>

Hoping someone can come back with how I can get rid of this problem.
Spent far too long on what should be the simplist of tasks. Many thanks




 
I'm not sure what to tell you.

On my system, when I use your code and point my browser to the first script, I get a couple of notices for uninitialized values and the form.

When I fill in the field and submit, I get the value returned and a link. (And another uninitialized variable notice).

When I click the link, I get the first page all over again, exactly as the first time. When I explicitly refresh the page, then I get the page showing a form with some of my data returned. It's not as well-formatted or as error-detecting as the code I posted, but it'll do.

I think you're running afoul of your browser's cache.



Want the best answers? Ask the best questions! TANSTAAFL!
 
Thanks, at least you get something back when index.php re-appears, as I get nothing. I get the data perfectly echoed back from process.php form, but nothing on final index.php's return. I have set my security to low on the browser, and assigned temporary internet file space to 10megs. As it is a Wamp5 installation (ie bundled package) would there be anything to gain pasting the configuration file php.ini up for comment. Regards
 
Hooooray!!!!!
It was the retched Wamp5 installation that was causing all this hell. I downloaded XAMPP which is another packaged PHP/Apache/MySql installation, and hey presto all my code works. So it was down to external bits. Have a star for your patience/help. Regards
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top