setQuery($sql); $cur = $mydb->loadSingleResult(); if ($cur->GRAVENO== $_POST['GRAVENO']) { # code... message("Grave number is already exists!","error"); redirect('index.php?view=add'); }else{ $autonumber = New Autonumber(); $res = $autonumber->set_autonumber('PEOPLEID'); $p = New Person(); $p->PEOPLEID = $res->AUTO; $p->FNAME = $_POST['FNAME']; // $p->LNAME = $_POST['LNAME']; // $p->MNAME = $_POST['MNAME']; $p->CATEGORIES = $_POST['CATEGORIES']; $p->BORNDATE = $borndate; $p->DIEDDATE = $dieddate; $p->LOCATION = $_POST['LOCATION']; $p->GRAVENO = $_POST['GRAVENO']; $p->create(); // } $autonumber = New Autonumber(); $autonumber->auto_update('PEOPLEID'); message("New Record created successfully!", "success"); redirect("index.php"); } } } } function doEdit(){ if(isset($_POST['save'])){ // $borndate = ($_POST['BORNDATE'] !='' || $_POST['BORNDATE'] !='0m/dd/yyyy') ? @date_format(date_create($_POST['BORNDATE']), "Y-m-d"): '0000-00-00'; // $dieddate = ($_POST['DIEDDATE'] !='' || $_POST['DIEDDATE'] !='0m/dd/yyyy') ? @date_format(date_create($_POST['DIEDDATE']), "Y-m-d") : '0000-00-00'; $borndate = $_POST['BORNDATE']; $dieddate = $_POST['DIEDDATE']; $p = New Person(); $p->FNAME = $_POST['FNAME']; // $p->LNAME = $_POST['LNAME']; // $p->MNAME = $_POST['MNAME']; $p->CATEGORIES = $_POST['CATEGORIES']; $p->BORNDATE = $borndate; $p->DIEDDATE = $dieddate; $p->GRAVENO = $_POST['GRAVENO']; $p->LOCATION = $_POST['LOCATION']; $p->update($_POST['PEOPLEID']); message("Record has been updated!", "success"); redirect("index.php"); } } function doDelete(){ if (isset($_POST['selector'])==''){ message("Select the records first before you delete!","error"); redirect('index.php'); }else{ $id = $_POST['selector']; $key = count($id); for($i=0;$i<$key;$i++){ $p = New Person(); $p->delete($id[$i]); message("Record has been Deleted!","info"); redirect('index.php'); } } } ?>