Enter Text"; } else if(empty($_POST["image"])) { $error = ""; } else if(empty($_POST["date"])) { $error = ""; } else { if(file_exists('news.json')) { $current_data = file_get_contents('news.json'); $array_data = json_decode($current_data, true); $extra = array( 'name' => $_POST['name'], 'image' => $_POST["image"], 'date' => $_POST["date"] ); $array_data[] = $extra; $final_data = json_encode($array_data); if(file_put_contents('news.json', $final_data)) { $message = "
"; } } else { $error = 'File not exits'; } } } ?>