$fileName = $_POST['fileName']; //posted value of text box
$userName =$_POST['userName']; //posted value of text box
$myFile = $fileName.".txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $userName;
fwrite($fh, $stringData);
fclose($fh);