setTPL("gpb_delete.tpl"); $form = new HTML_QuickForm("NewForm"); //}}} function process_data($args) { /** * Process Data * * This is the callback function to handle the processing of the QF * @author Tristan Coetzee * @param $args Contains the form variables supplied by HTML_QF * @version 0.1.0 */ global $db; global $form; $msg = ''; if (isset($args['btnDelete'])&&('Confirm Deletion!'==$args['btnDelete'])) { $form->addElement('header',"hdrConfirm","Are you sure you want to delete this entry?"); $ele=&$form->getElement('btnDelete'); $ele->setValue('Delete Entry!'); } if (isset($args['btnDelete'])&&('Delete Entry!'==$args['btnDelete'])) { $del_query = 'DELETE FROM `global_phone_book` WHERE gpb_id='.$args['gpb_id'].';'; $del_res = $db->query($del_query); if(handleError($del_res)) { $msg = 'Entry Deleted Successfully!'; } else { $msg = 'Error: Entry could not be Deleted!'; } } return $msg; } //end of process_data callback function //{{{ do some basic validation on the posted id $gpb_id=$_POST['gpb_id']; $tpl->assign('gpb_id',$gpb_id); //}}} //{{{ retrieve details from db $query = "SELECT * FROM `global_phone_book` WHERE `gpb_id` = $gpb_id"; $res = $db->query($query); if(handleError($res)) { $res->fetchInto($row); } //}}} //{{{ add basic form elements $form->addElement('header',"hdrTop","Delete User"); $form->addElement('header',"hdrName",$row['gpb_name']); $form->addElement('header',"hdrNumber",$row['gpb_number']); $form->addElement('header',"hdrType",$row['gpb_type']); $form->addElement('submit','btnDelete','Confirm Deletion!'); //}}} //{{{ validate form if($form->validate()) { $result = $form->process('process_data','false'); $form->addElement('text','txtResult',$result); } else { } //}}} //{{{ assign form to tpl and display form $tpl->display(&$form); //}}} ?>