02-14-2019, 01:58 PM
I am new to UserSpice, and I have recently started working with another group on a project that has been developed using UserSpice.
There is an issue we have encountered where an entry can be edited but when performing the DB Update, the record is not updated.
I'm still learning the framework and I can see the DB.php file and the functions, and it seems to me the db->update should work but I'm not sure why it does not.
From the following can anyone glean why it would not update?
Thanks for any assistance anyone can provide.
?>
<?php require_once '../users/init.php'; ?>
<?php require_once $abs_us_root.$us_url_root.'users/includes/header.php'; ?>
<?php require_once $abs_us_root.$us_url_root.'users/includes/navigation.php'; ?>
<?php if (!securePage($_SERVER['PHP_SELF'])){die();} ?>
<?php
$validation = new Validate();
//PHP Goes Here!
$errors = [];
$successes = [];
$rtuId = Input::get('id');
//Check if selected user exists
if(!rtuIdExists($rtuId)){
Redirect::to("company_admin_rtus.php"); die();
}
$rtudetails = fetchRTUDetails(NULL, NULL, $rtuId); //Fetch rtu details
$str = $rtudetails->org_id;
$str .= $rtudetails->rtu_id;
//Forms posted
if(!empty($_POST)) {
$token = $_POST['csrf'];
if(!Token::check($token)){
die('Token doesn\'t match!');
}else {
//set changed bit in database
$configchanged=array(
'configChange' => 1,
);
//Update rtu name
if ($rtudetails->rtu_name != $_POST['rtu_name']){
$rtu_name = Input::get("rtu_name");
$fields=array('rtu_name'=>$rtu_name);
$validation->check($_POST,array(
'rtu_name' => array(
'display' => 'rtu_name',
'required' => true,
'min' => 1,
'max' => 50
)
));
if($validation->passed()){
$db->update('rtu_act', $rtuId, $fields);
$successes[] = "RTU Name Updated";
}else{
?><div id="form-errors">
<?=$validation->display_errors();?></div>
<?php
}
}
There is an issue we have encountered where an entry can be edited but when performing the DB Update, the record is not updated.
I'm still learning the framework and I can see the DB.php file and the functions, and it seems to me the db->update should work but I'm not sure why it does not.
From the following can anyone glean why it would not update?
Thanks for any assistance anyone can provide.
?>
<?php require_once '../users/init.php'; ?>
<?php require_once $abs_us_root.$us_url_root.'users/includes/header.php'; ?>
<?php require_once $abs_us_root.$us_url_root.'users/includes/navigation.php'; ?>
<?php if (!securePage($_SERVER['PHP_SELF'])){die();} ?>
<?php
$validation = new Validate();
//PHP Goes Here!
$errors = [];
$successes = [];
$rtuId = Input::get('id');
//Check if selected user exists
if(!rtuIdExists($rtuId)){
Redirect::to("company_admin_rtus.php"); die();
}
$rtudetails = fetchRTUDetails(NULL, NULL, $rtuId); //Fetch rtu details
$str = $rtudetails->org_id;
$str .= $rtudetails->rtu_id;
//Forms posted
if(!empty($_POST)) {
$token = $_POST['csrf'];
if(!Token::check($token)){
die('Token doesn\'t match!');
}else {
//set changed bit in database
$configchanged=array(
'configChange' => 1,
);
//Update rtu name
if ($rtudetails->rtu_name != $_POST['rtu_name']){
$rtu_name = Input::get("rtu_name");
$fields=array('rtu_name'=>$rtu_name);
$validation->check($_POST,array(
'rtu_name' => array(
'display' => 'rtu_name',
'required' => true,
'min' => 1,
'max' => 50
)
));
if($validation->passed()){
$db->update('rtu_act', $rtuId, $fields);
$successes[] = "RTU Name Updated";
}else{
?><div id="form-errors">
<?=$validation->display_errors();?></div>
<?php
}
}