Chcialbym zapytac co jest w tym kodzie zle

mi sie wydaje ze
Kod
if ($p) {
$query = "UPDATE users SET password=PASSWORD('$p') WHERE user_id={$_SESSION['user_id']}";
$result = mysql_query ($query);
if (mysql_affected_rows() == 1)
{
$query = "UPDATE users SET password=PASSWORD('$p') WHERE user_id={$_SESSION['user_id']}";
$result = mysql_query ($query);
if (mysql_affected_rows() == 1)
{
cos tutaj
ale tutaj macie caly kod
Kod
<?php
if (!isset($_SESSION['first_name'])) {
header ("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "index.php");
ob_end_clean();
exit();
} else {
if (isset($_POST['submit'])) {
if (isset($_POST['password']) == isset($_POST['password2'])){
$p = isset($_POST['password1']);
} else {
$p = FALSE;
echo '<p><font size="3">New password is not identical to your first entry!</font></p>';
}
} else {
echo '<p><font size="3">Please enter password!</font></p>';
}
if ($p) {
$query = "UPDATE users SET password=PASSWORD('$p') WHERE user_id={$_SESSION['user_id']}";
$result = mysql_query ($query);
if (mysql_affected_rows() == 1)
{
echo '<font color="#33CC00"><h1>Congratulations,</h1><br><font color="#33CC00">Password changed successfully!<br><small>This page automatically refreshes every 5 seconds!';
exit();
} else {
echo '<font color="red">Sorry for all inconvenience!</font><br />';
}
mysql_close();
} else {
echo '<font color="red">Try again!</font><br />';
}
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<p><small>New password:<font color="red">*</font> </small></b><input type="password" name="password1" size="20" maxlength="20"></p>
<p><small>Confirm password:<font color="red">*</font> </small></b><input type="password" name="password2" size="20" maxlength="20"></p>
<div align="center"><input type="submit" name="submit" value="Change"></div>
</form>
if (!isset($_SESSION['first_name'])) {
header ("Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "index.php");
ob_end_clean();
exit();
} else {
if (isset($_POST['submit'])) {
if (isset($_POST['password']) == isset($_POST['password2'])){
$p = isset($_POST['password1']);
} else {
$p = FALSE;
echo '<p><font size="3">New password is not identical to your first entry!</font></p>';
}
} else {
echo '<p><font size="3">Please enter password!</font></p>';
}
if ($p) {
$query = "UPDATE users SET password=PASSWORD('$p') WHERE user_id={$_SESSION['user_id']}";
$result = mysql_query ($query);
if (mysql_affected_rows() == 1)
{
echo '<font color="#33CC00"><h1>Congratulations,</h1><br><font color="#33CC00">Password changed successfully!<br><small>This page automatically refreshes every 5 seconds!';
exit();
} else {
echo '<font color="red">Sorry for all inconvenience!</font><br />';
}
mysql_close();
} else {
echo '<font color="red">Try again!</font><br />';
}
}
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<p><small>New password:<font color="red">*</font> </small></b><input type="password" name="password1" size="20" maxlength="20"></p>
<p><small>Confirm password:<font color="red">*</font> </small></b><input type="password" name="password2" size="20" maxlength="20"></p>
<div align="center"><input type="submit" name="submit" value="Change"></div>
</form>
z gory dziekuje ;d