Hi guys i can write text file and also can read it. below are the codes.
[PHP]
<?PHP
//write to a file
$body_content=" This is my content"; // Store some text to enter inside the file
$file_name="tes t_file.txt"; // file name
$fp = fopen ($file_name, "w");
// Open the file in write mode, if file does not exist then it will be created.
fwrite ($fp,$body_cont ent); // entering data to the file
fclose ($fp); // closing the file pointer
chmod($file_nam e,0777); // changing the file permission.
?>
[/PHP]
[PHP]
<?
//reading file
$myFile = "test_File.txt" ;
$fh = fopen($myFile, 'r');
//$theData = fread($fh,5);
$theData = fread($fh, filesize($myFil e));
fclose($fh);
echo $theData;
?>
[/PHP]
I have a form where i have 3 fields (name, date and info). i m storing it into mysql database. now i need to store it into the database as well as also into a text flie. please show me the proper way to solve it
[PHP]
<?PHP
//write to a file
$body_content=" This is my content"; // Store some text to enter inside the file
$file_name="tes t_file.txt"; // file name
$fp = fopen ($file_name, "w");
// Open the file in write mode, if file does not exist then it will be created.
fwrite ($fp,$body_cont ent); // entering data to the file
fclose ($fp); // closing the file pointer
chmod($file_nam e,0777); // changing the file permission.
?>
[/PHP]
[PHP]
<?
//reading file
$myFile = "test_File.txt" ;
$fh = fopen($myFile, 'r');
//$theData = fread($fh,5);
$theData = fread($fh, filesize($myFil e));
fclose($fh);
echo $theData;
?>
[/PHP]
I have a form where i have 3 fields (name, date and info). i m storing it into mysql database. now i need to store it into the database as well as also into a text flie. please show me the proper way to solve it
Comment