"; $bdate = "
"; $btitle = ""; $etitle = "

update "; $edate = "

"; $bpost = ""; $epost = ""; $etable = "

"; //Define PHP Date format. Used for the default date form value. $defdate=date("d-m-Y"); //Other notes //The date is automatically set to todays date by using PHP to echo the variable of defdate. The form action uses this file itself to process the data. // The If/Else statements decide what is displayed based on whether a HTTP GET or POST was issued by the browser. GET: If the submit button has not been // pushed -- display form. PUT: Submit button has been pushed -- write data to text file and display confirmation message. //IF browser does not send a POST request (ie: if submit has not been pressed) then display the form.... if ($_SERVER['REQUEST_METHOD'] != 'POST'){ //If able to open file do... if ($file) { ?>
Activiteiten & News: Post

Simple News: Error

Could not open file.

"; } //ELSE IF browser sends a POST request. Make sure that data was actually //entered into the form and then write that data to the file.... elseif ((isset($_REQUEST["title"])) && (isset($_REQUEST["date"])) && (isset($_REQUEST["post"])) && ($_REQUEST["title"]!="") && ($_REQUEST["date"]!="") && ($_REQUEST["post"]!="")) { //The next few lines are a hacked up way to "add" text to the top of a file. The file is already opened in read mode. Read in all the current data from news.txt. Save this as variable current_data. $current_data = @fread($file, filesize($newsfile)); //Now that we have saved the old data to a variable lets close the file. fclose($file); //Now we reopen the file in write mode. This FIRST blanks the file. Then will will write the new data followed by the old data to the file. $file = fopen($newsfile, "w"); //Write all of the table variables and the text entered into the form, plus the text that was already in news.txt to news.txt. The \n is a new line and it //simply make news.txt more beautiful. If it works display success message, if not display failure message. //// Fix quotes (') in entries and change any weird //characters (&,<,>,etc) to their html equivalents. Do the same for title and //date. Even though it should not be needed for date. $_REQUEST["post"] = stripslashes(($_REQUEST["post"])); $_REQUEST["date"] = stripslashes(($_REQUEST["date"])); $_REQUEST["title"] = stripslashes(($_REQUEST["title"])); if(fwrite($file,$btable . " " . $btitle . " " . $_REQUEST["title"] . " " . $etitle . " " . $bdate . " " . $_REQUEST["date"] . " " . $edate . " " . $bpost . " " . $_REQUEST["post"] . " " . $epost . " " . $etable . "\n " . $current_data)) echo "Bericht succesvol toegevoegd.

Voeg nog een bericht toe.    Terug naar Actueel."; else echo "Simple News: Entry NOT Added!

Could not add entry.

"; //Close the file. fclose($file); } //If the browser sent a POST request but the user failed to put data in the //form...spit out this error. else echo "Simple News: Entry NOT Added!

Could not add entry.
All the fields in the form are *required*.
Please go back and try again.

"; ?>