im trying to change the password of the signed in user but when i run the code it always changes the top row of the table and the signed in user is somewhere in the middle.
the code for the user
validation code
<?php
session_start();
include ('dbc.php');
if (!isset($_SESSION['user'])) {
header("Location: login.php");
}
$id = mysql_real_escape_string($_SESSION['id']);
$todo=$_POST['todo'];
$oldpwd=$_POST['oldpwd'];
$newpwd=$_POST['newpwd'];
if ($_POST['Submit']=='Change') {
$result = mysql_query("select * from users where id='$id'")
or die("asdasdsd".mysql_error());
while($row=mysql_fetch_array($result)) {
if ($_POST["oldpwd"] == $row["user_pwd"]) {
mysql_query("UPDATE users set user_pwd='$newpwd' WHERE id='$id'");
header("Location: userpanel.php?msg=Password updated...");
} else {
header("Location: userpanel.php?msg=ERROR: Password does not match...");
}
}
}
?>