2. Flat File .txt + PHP Database Tutorial - Allow user or client to change data - CMS

Flat File .txt + PHP Database Tutorial - Allow user or client to change data - CMS

Listening Video

In this lesson series Adam Khoury demonstrates using .txt Flat File Database systems as an alternative to MySQL, XML, or other database systems. In part 2 you will learn how to allow a user or client to change the data from smart easy web forms. Many people do not have tech knowledge and do not like going on the server to alter a CMS file. You must make forms to alter the data if you wish to have happier higher paying clients.
Lesson Code
<?php
$myfile 
"file1.txt";
if (isset(
$_POST['ta'])) {
    
$newData nl2br(htmlspecialchars($_POST['ta']));
    
$handle fopen($myfile"w");
    
fwrite($handle$newData);
    
fclose($handle);
}
// ------------------------------------------------if (file_exists($myfile)) {

    
$myData file_get_contents($myfile);
}
?>Hello user, use this form to edit the writing on your live website
<form action="file.php" method="post">
<textarea name="ta" cols="64" rows="10">
<?php echo str_replace("<br />","",$myData); ?></textarea>
<br /><br />
<input name="myBtn" type="submit" />
</form>
<br /><br />
<?php echo $myData?>

0 Response to "2. Flat File .txt + PHP Database Tutorial - Allow user or client to change data - CMS"

Post a Comment