<?php
}
else
{
//Form submitted, grab the data from POST $textinputs =trim($_POST['textinputs']);
//Test if it contains some data.
if (!isset($textinputs) || trim($textinputs) == "")
{
//Feedback to user that it contains no data
die ('ERROR: Enter your text. <a href="/phpformtotextfilebasic">Click here to proceed.</a>');
}
else
{
//Set file and the path to write $filepath='/opt/lampp/htdocs/phpformtotextfilebasic/textfolder/writethistextfile.txt';
//Open file in writing mode $filehandler= fopen($filepath, 'w') or die('ERROR: Could not open file!');
//Write text to file
fwrite($filehandler,$textinputs) or die('ERROR: Could not write to file');
//Close file fclose($filehandler);
echo 'Your text has been written to the file successfully.<br />';
echo '<a href="/phpformtotextfilebasic">Enter another text.</a>';
}
}
?>
blog comments powered by Disqus |
|
|
|
|
|
|
|