Answer the question
In order to leave comments, you need to log in
Why don't the values add up?
The essence of the question is that I wrote the code, the code is written in such a way that when the button is pressed, it transfers to a file with post processing, the value from the database and from the post should be added there, then written to the database, but the jamb is that the value is not develops where the error I found.
<?php
require 'includes/db.php';
$title = "Профиль";
$act = 'profile';
session_start();
$data = $_POST;
if (isset($data['do_accept'])) {
//подтверждаем
$errors = array();
if (trim($data['idp']) == '') {
$errors[] = 'Введите id пользователя!';
}
if (trim($data['colrep']) == '') {
$errors[] = 'Введите кол-во выговоров';
}
if (trim($data['why']) == '') {
$errors[] = 'Введите значение 1 или 0 (1-Да, 0-Нет.)';
}
$qurr = R::getAll( 'SELECT * FROM user WHERE id=?', array($data['idp']) );
$colrepp = $qurr['rep']+$data['colrep'];
if (empty($errors)) {
$userp = R::dispense('user');
$userp->id = $data['idp'];
$userp->accept = $data['acceptp'];
$userp->rep = $colrepp;
$userp->whyrep = $data['why'];
R::store($userp);
$cmplt = '<div style="color:green;padding-left:35%; float:left; width:30%;">Вы успешно выдали выговор!</div>';
echo '<script>window.location.href = "profile.php";</script>';
return;
} else {
$error = '<div style="color:red;padding-left:35%; float:left; width:30%;">'.array_shift($errors).'</div>';
}
}
?>
Answer the question
In order to leave comments, you need to log in
Look through var_dump()
:
Is the POST coming correctly
And each request also check what it returns
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question