I am trying to set up a daily specials page for my website. I want the chefs to be able to fill out a form online and have the info they type into the form show up on the daily specials page on the website. I am very new to programming and I don't know PHP at all so I wonder if there is a simple way to do this that I just don't know about.
I can do this with a database easily enough however I can not set up a database for this site. Long story, don't ask.
I can use PHP to transfer data from the form online that is filled out by the chefs to the daily specials page - but the data does not stay there once the form is closed. I have tried using onSubmit return false on the form to keep it from being cleared but that did not work. Is there another way to do this or did I do it wrong?
I can use local storage to keep the info from the form and use jQuery to take the data from the form and put it on the daily specials page - but that only works for my machine. Is there anything like local storage for a server or for a domain name?
I tried embedding a google doc and a google sheet - Google's documentation reads that the sheets will automatically update on the website where they are embedded when changes are made to the sheet but that is not the case - or at least i have not managed to get it to work. Also the CSS is very limited so they do not look very good.
I can get info from an .html and .txt to my daily specials page using jQuery.load() - but how do i get the info onto the html or the txt file first? The text file needs to be on the server or on line so the chefs have access to it and the website has access to it. I can write to a .txt using PHP and an html form but I have not been able to put it all together.
Using these very simple pages:
form.html
<form action="action.php" method="POST">
<input name="field1" type="text" />
<input name="field2" type="text" />
<input type="submit" name="submit" value="Save Data">
</form>
action.php
<?php
if(isset($_POST['field1']) && isset($_POST['field2'])) {
$data = $_POST['field1'] . '-' . $_POST['field2'] . "\r\n";
$ret = file_put_contents('mydata.txt', $data, FILE_APPEND | LOCK_EX);
if($ret === false) {
die('There was an error writing this file');
}
else {
echo "$ret bytes written to file";
}
}
else {
die('no post data to process');
}
load.html
<b>Projects:</b>
<ol id="cafe"></ol>
<script>
$( "#cafe" ).load( "mydata.txt" );
</script>
I have been able to fill out a form - write that data to a text file - grab that data off the text file and add it to an html page - but how do i get it to do all that and look good? I don't know how to set it up so that when it adds the data the text file it adds a specific piece of data into a specific div so then i can call that specific div onto my html page and add CSS to it? Do i have to make a new .txt file for each new piece of data?
I have 5 things that need to be updated per restaurant and i have 4 restaurants.
So I would have:
restaurant A - I would need to update, 1. chef name. 2. special name, 3. special description, 4. kid's special name, 5. kid's special description.
restaurant B - I would need to update, 1. chef name. 2. special name, 3. special description, 4. kid's special name, 5. kid's special description.
restaurant C - I would need to update, 1. chef name. 2. special name, 3. special description, 4. kid's special name, 5. kid's special description.
restaurant D - I would need to update, 1. chef name. 2. special name, 3. special description, 4. kid's special name, 5. kid's special description.
Nothing would need to be saved just replaced -
So right now i think i can do it if i write each new piece of data to a different txt file. so restaurant A would have chefname.txt, specialname.txt, specialdescription.txt, kidspecial.txt and kiddescription.tx.
Does anyone have ideas of a better way to do this? It seems like it would be a simple thing to do and I am just very new and don't know what I should be doing to accomplish this.