Help needed with fwrite
Posted: Mon Jun 15, 2009 11:58 pm
I have an form in which when the user types first name, that data should be written in a .txt file. Below is the code with which the a .txt file is created. When $string_data is passed ,it passes the data "How are you" to textFile.txt but how can I pass the contents of a text field name "FirstName" to "textFile.txt". I appreciate any help.
Code: Select all
if(isset($_POST['Submit']))
{
touch("textFile.txt");
$FirstName = $_POST['FirstName'];(this doesn't seems to be working)
$myfile = "textFile.txt";
$fh = fopen($myfile,'w') or die("Can't open the file"):;
//$string_data = "How are you";
fwrite ($fh, $FirstName);
fclose($fh);