PHP Forms with Write

Joined
Dec 31, 2004
Messages
4,086
Reaction score
25
Hey Guys,

Basically what I am trying to do is to create a form where someone will enter their name or whatever, then save that name as a .txt file. Then it will input some data into that text file... well have a few issues.

Form:
Code:
<h1 align="center">Name Validator </h1>    
	
	<form action="proc.php" method="post">
File Name:
  <input name="name" type="text" />
  <br>
 Text:
  <input name="text" type="text" />
<input type="submit" value="GO!" />
</form>

proc.php:
Code:
<?php
$myFile = "echo $_POST['name'].txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "echo $_POST['text']";
fwrite($fh, $stringData);
fclose($fh);
?>

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in W:\www\proc.php on line 4

So confused, this is my first time doing this sort of thing.
 
Back