Forum Moderators: coopster
(The PHP program file will read this in as "5", "7" and "3").
The server spits back the numbers to the user via a HTML page. But the output also contains a text field to accept a number. The user can input various numbers, BUT the PHP program is PAUSED while it waits for more the user to complete this second form to send more information.
Any idea how to do this? Unfortunately, the PHP interpreter will go through the rest and not pause to wait for more user input. Here's the code with one or two important comments to signify what I want done.
***************CONTENTS OF TEXT FILE: "573"
***************CONTENTS OF HTML FILE: "test.html"
<html><head></head>
<body>
This form uploads a file to the server.<br>
<form enctype="multipart/form-data" action="getfile.php" method="POST">
<input type="hidden" name="MAX_FILE_SIZE" value="100000">
Choose a file to upload: <input name="uploadFile" type="file">
<input type="submit" value="Upload File">
</form>
</body></html>
***************CONTENTS OF PHP FILE: "getfile.php"
<html><body>
<?php
$f=fopen($_FILES['uploadFile'] ['tmp_name'], "r");
while (!feof($f)) { $x=fgetc($f); echo $x+1; }
?>
<br><br>
<form enctype="multipart/form-data" action="getfile.php" method="POST">
Choose a file to upload: <input name="uploadFile" type="file"><br>
<input type="submit" value="Upload File">
</form>
<br><br>
// AT THIS POINT IN THE CODE, I WANT PHP TO WAIT
// UNTIL THE ABOVE SECOND FORM HAS BEEN COMPLETED
<?php
$f=fopen($_FILES['uploadFile'] ['tmp_name'], "r");
while (!feof($f)) { $x=fgetc($f); echo $x+2; }
?>
</body></html>
If you want the data from the previous post to be availible the next time it executes you will either have to keep track of it yourself (database/textfile) or make sure it is reposted every time by including it as a hidden form field in the html you serve them after the first time (simple and requires no keeping track of sessions etc).
The arrays can usually be sent back and forth as long as you're using POST instead of GET. Not sure how convenient it will be though. Sessions sound better.