read up on these functions they will allow you to do this:[man]fopen[/man] , [man]fwrite[/man], and [man]fclose[/man]
just make sure that whatever user your webserver is running as has permission to read and write to the directory you are storing files in.
sounds though, that you might want to look into something called a Relational Database (MySql or PostgreSql for example) this will remember information that a user has typed into a form.
here is an example that has your php file actually dynamically create another executable .php file.
<?php
$value = 5;
$file = '/path/to/file.php';
$file_pointer = fopen( $file, 'w' );
$string = '<?php $var = '. $value .' ?>';
fwrite( $file_pointer, $string );
fclose($file_pointer);
include($file);
echo $var;
?>