Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include 'conexion.php';
- $id = $_POST['id'];
- $texto = $_POST['texto'];
- $columna = $_POST['columna'];
- $consulta ="UPDATE usuarios SET :columna = :texto WHERE id = :id";
- $statement = $con->prepare($consulta);
- $statement->bindParam(':id', $id);
- $statement->bindParam(':texto', $texto);
- $statement->bindParam(':columna', $columna);
- $statement->execute();
- if(!$statement){
- echo 'Error al actualizar';
- }else{
- echo 'Se han actualizado los datos';
- }
- ?>
- $(document).on("blur", "#nombre", function(){
- var id = $(this).data("id_user");
- var nombre = $(this).text();
- actualizar_datos(id, nombre, "nombre");
- });
- function actualizar_datos(id, texto, columna){
- $.ajax({
- url: "actualizar.php",
- method: "POST",
- data: {
- id: id,
- texto: texto,
- columna: columna
- },
- success: function(data){
- obtener_datos();
- alert(data);
- }
- })
- }
Add Comment
Please, Sign In to add comment