3
Good afternoon
I’m trying to update the database and I can’t. If I use mysqli, the following warning appears on the console: "http://localhost:8888/systems/systems_web/Vigilantescomunitarios/admin/php/updateUsuario.php 500 (Internal Server Error)"
If I use mysql and PDO connection, nothing happens, nor notice on the console appears.
My js file:
app.controller("AtualizarUsuarioController", function ($scope, $window, $http, $location) {
$scope.usuario = {
'id': $window.localStorage.getItem('idUsuarios'),
'nome': $window.localStorage.getItem('nome'),
'email': $window.localStorage.getItem('email')
}
//$location.path('/atualizarUsuario' + $scope.usuario.id);
$scope.atualizarUsuario = function (usuario) {
$http.post("admin/php/atualizarUsuario.php", usuario).then(function (data){
$location.path("#/usuarios");
});
};
});
php:
<?php
header("Access-Control-Allow-Origin: *");
include_once ("conPDO.php");
$pdo = conectar();
$postdata = file_get_contents("php://input");
$data = json_decode($postdata);
$id = $data->id;
$nome = $data->nome;
$email = $data->email;
$senha = $data->senha;
$senha = sha1($senha);
$usuarioAtual=$pdo->prepare("UPDATE usuarios SET nome=:nome, email=:email, senha=:senha WHERE id=:id");
$usuarioAtual->bindValue(":nome", $nome);
$usuarioAtual->bindValue(":email", $email);
$usuarioAtual->bindValue(":senha", $senha);
$usuarioAtual->bindValue(":id", $id);
$usuarioAtual->execute();
Already checked if the URL of the Api is correct, I do not know php but I would put a print in the method that updates to see if it is being called
– DiegoAugusto
Yes, the url is correct. I use the Postman, Chrome application, to check this and pass data.
– GustavoSevero
You could post the code of the files "con.php" and "conPDO.php"?
– João Carvalho
@Gustavosevero Internal error means there was a server crash. Go to the Networks tab of the browser and check the file updateUsuario.php that will have the server’s answer containing the error. If not, check the server logs.
– Marco Aurélio Deleu