date = time(); $currentPost->name = htmlentities($_POST["name"]); $currentPost->message = htmlentities($_POST["message"]); $currentPost->found = htmlentities($_POST["found"]); if($_POST["website"]) $currentPost->website = $_POST["website"]; if($_POST["cool"]) $currentPost->cool = $_POST["cool"]; $currentPost->reply = ""; $filename = "posts.json"; $handle = @fopen($filename, 'r+'); // create the file if needed if ($handle === null) { $handle = fopen($filename, 'w+'); } if ($handle) { // seek to the end fseek($handle, 0, SEEK_END); // are we at the end of is the file empty if (ftell($handle) > 0) { // move back a byte fseek($handle, -2, SEEK_END); // add the trailing comma fwrite($handle, ",\n", 2); // add the new json string fwrite($handle, json_encode($currentPost) . "]\n"); } else { // write the first event inside an array fwrite($handle, json_encode(array($currentPost))); } // close the handle on the file fclose($handle); } } } header("Location: ./?return=$returnCode"); ?>
Your post has been submitted! It's weird that you're seeing this page though. Maybe your browser can't process location headers? At any rate, click here"; ?> to get where you're supposed to be right now.