X-Git-Url: https://jasonwoof.com/gitweb/?p=wfpl-cms.git;a=blobdiff_plain;f=admin_files.php;h=4b6ae043616b9f1c10ddad91664f736cc50a71d3;hp=ba0e507ae01f99f8534300ad6a328a2a2efef8dd;hb=033b3723557ef39ca72c8440ba1c1a49dd47b319;hpb=c469d2530ad9684e56742d38f5817cb08ad98eef diff --git a/admin_files.php b/admin_files.php index ba0e507..4b6ae04 100644 --- a/admin_files.php +++ b/admin_files.php @@ -1,21 +1,6 @@ 'Yes'); - $data = array(); - } - - tem_set('upload_max_filesize', upload_max_filesize()); - - tem_set('form', $data); + if($id) { + tem_set('id', $id); + } + + if(isset($_POST['description'])) { + $data = admin_files_get_fields(); + + if("you're happy with the POSTed values") { + if($id) { + db_update_assoc('files', $data, 'where id=%i', $id); + message('File updated.'); + } else { + db_insert_assoc('files', $data); + message('File saved.'); + } + if($error !== true) { + return './admin_files'; + } + } + # otherwise, we display the form again. admin_files_get_fields() has + # already put the posted values back into the template engine, so they will + # show up in the form fields. You should add some message asking people to + # fix their entry in whatever way you require. + } elseif($id) { + # we've recieved an edit id, but no data. So we grab the values to be edited from the database + $data = db_get_assoc('files', ADMIN_FILES_DB_FIELDS, 'where id=%i', $id); + } else { + # form not submitted, you can set default values like so: + #$data = array('description' => 'Yes'); + $data = array(); + } + + tem_set('upload_max_filesize', upload_max_filesize()); + + tem_set('form', $data); }