Adding (appending) a message from web page to semicolon database in a text file put file contents?

Here is what my database looks like…
MSG 0 ; ;
MSG 1 ; ;
MSG 2 ; ;
MSG 3 ; ;
My goal is to insert (append) a 40 char message to the empty column you see before you… The datafile is called message.txt and I want to insert it between the two semicolons in column 1

Here’s what I have with regards to inserting however it just dumps the info into a text file…

<?php
$companyfile = "message.txt";
if (isset($_POST['company'])) {
$newData = nl2br(htmlspecialchars($_POST['company']));

}
// ----------------------------
if (file_exists($companyfile)) {

$companyData = file_get_contents($companyfile);
}
?>

and from what I read I need to integrate this

file_put_contents($file, $content, FILE_APPEND);

but I can’t figure it out to do so… Can someone help me out? Thank you…

Please show a sample of how your file should look like after updating and what is in $_POST['company']

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.