New question

Question:

Date: 21-10-2020 15:50:59 (In Spanish)

porque no me cambia los datos de mi tabla?[Unresolved]

me devuelve a la pagina, pero los dato no se cambian ¿Por qué es? ayuda pliss

<?php include('session.php'); ?>

<?php
$query = $conn->query("select * from user where id_user = '$session_id'");
$row = $query->fetch();
$id = $row['id_user'];
?>
<h1 class="title">Editar Mi Perfil</h1>
<form method="post" action="perfilPhp/save_edit.php">
<input type="hidden" name="id_user" value="<?php echo $id; ?>">
<h3 id="imgPer">Imagen del perfil</h3>
<img class="userImgEdit" src="<?php echo $image; ?>" height="140" width="160">
<div class="divofdiv">
<p id="tf1">Cambiar imagen</p>
<input type="file" id="caraI" accept="img/*">
</div>
<h3 id="nameUser">Nombre de usuario</h3>
<input type="text" name="username" class="nameEdit" value="<?php echo $row['username']; ?>">
<h3 id="email">Correo electronico</h3>
<input type="text" id="emailI" class="emailEdit" name="email" value="<?php echo $row['email']; ?>">
<h3 id="pass">Contraseña</h3>
<input type="text" id="passI" class="passEdit" name="password" value="<?php echo $row['password']; ?>">
<button name="save" id="SaveC" class="btn edit">Guardar cambios</button>

SESSION.PHP

<?php
session_start();
if (!isset($_SESSION['id'])){
header('location:index.html');
}
$session_id = $_SESSION['id'];
$session_query = $conn->query("select * from user where id_user = '$session_id'");
$user_row = $session_query->fetch();
$username = $user_row['nombre']." ".$user_row['lastname'];
$image = $user_row['image'];
?>

SAVEEDIT.PHP

<?php
include('conP.php');

$member_id = $_POST['id_user'];
$username = $_POST['username'];
$email = $_POST['email'];
$password = $_POST['password'];

$conn->query("update user set username = '$username',email = $email,password = $password where id_user = '$member_id'");

?>

<script>
window.location = '../perfilEdit.php<?php echo '?id='.$member_id; ?>';
</script>
Tags: Database - MySQL - PHP - PHP MySQLi - Question - SQL Votes: 0 - Answers: 2 - Views: 8 Share on: Google Facebook Twitter LinkedIn Link
 

Answers:

  • Date: 22-10-2020 06:59:14 Hola Benjamín, veo en el código es que estás tratando el id como un string, probá cambiando
    $conn->query("update user set username = '$username',email = $email,password = $password where id_user = '$member_id'");
    por
    $conn->query("update user set username = '$username', email = '$email', password = '$password' where id_user = $member_id");
    Espero que te sirva, saludos.
      Votes: 1 - Link answer
     
  • Date: 22-10-2020 14:07:17 si funciono amigo, muchas gracias :)   Votes: 0 - Link answer
     
To actively participate in the community first must authenticate, enter the system.Sign In