Доброго времени суток, я не так силён в программировании, поэтому прошу вашей помощи.
Есть форма:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
<div class='box_two_title'>Сменить пароль</div>
<?php
account::isNotLoggedIn();
if (isset($_POST['change_pass']))
account::changePass($_POST['cur_pass'],$_POST['new_pass'],$_POST['new_pass_repeat']);
?>
<form action="?p=changepass" method="post">
<table width="70%">
<tr>
<td>Новый пароль:</td>
<td><input type="password" name="new_pass" class="input_text"/></td>
</tr>
<tr>
<td>Повторите новый пароль:</td>
<td><input type="password" name="new_pass_repeat" class="input_text"/></td>
</tr>
<tr>
<td></td>
<td><hr/></td>
</tr>
<tr>
<td>Введите текущий пароль:</td>
<td><input type="password" name="cur_pass" class="input_text"/></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="Сменить пароль" name="change_pass" /></td>
</tr>
</table>
</form>
А также:
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
//Used for the change password page.
public static function changePass($old,$new,$new_repeat)
{
$_POST['cur_pass']=mysql_real_escape_string(trim($old));
$_POST['new_pass']=mysql_real_escape_string(trim($new));
$_POST['new_pass_repeat']=mysql_real_escape_string(trim($new_repeat));
//Check if all field values has been typed into
if (!isset($_POST['cur_pass']) || !isset($_POST['new_pass']) || !isset($_POST['new_pass_repeat']))
echo '<b class="red_text">Пожалуйста, заполните все поля!</b>';
else
{
//Check if new passwords match?
if ($_POST['new_pass'] != $_POST['new_pass_repeat'])
echo '<b class="red_text">Новый пароль не принят!</b>';
else
{
if (strlen($_POST['new_pass']) < $GLOBALS['registration']['passMinLength'] ||
strlen($_POST['new_pass']) > $GLOBALS['registration']['passMaxLength'])
echo '<b class="red_text">Ваш пароль должен быть от 6 до 32 символов</b>';
else
{
//Lets check if the old password is correct!
$username = strtoupper(mysql_real_escape_string($_SESSION['cw_user']));
connect::selectDB('logondb');
$getPass = mysql_query("SELECT `sha_pass_hash` FROM `account` WHERE `id`='".$_SESSION['cw_user_id']."'");
$row = mysql_fetch_assoc($getPass);
$thePass = $row['sha_pass_hash'];
$pass = mysql_real_escape_string(strtoupper($_POST['cur_pass']));
$pass_hash = strtoupper(sha1($username.':'.$pass));
$new_pass = mysql_real_escape_string(strtoupper($_POST['new_pass']));
$new_pass_hash = sha1($username.':'.$new_pass);
if ($thePass != $pass_hash)
echo '<b class="red_text">Не правильный старый пароль!</b>';
else
{
//success, change password
echo 'Пароль был изменен!';
mysql_query("UPDATE account SET sha_pass_hash='".$new_pass_hash."' WHERE id='".$_SESSION['cw_user_id']."'");
mysql_query("UPDATE account SET v='0' AND s='0' WHERE username='".$username."'");
}
}
}
}
}
public static function changePassword($account_name,$password)
{
$username = mysql_real_escape_string(strtoupper($account_name));
$pass = mysql_real_escape_string(strtoupper($password));
$pass_hash = sha1($username.':'.$pass);
connect::selectDB('logondb');
mysql_query("UPDATE `account` SET `sha_pass_hash`='$pass_hash' WHERE `id`='".$_SESSION['cw_user_id']."'");
mysql_query("UPDATE `account` SET `v`='0' AND `s`='0' WHERE id='".$_SESSION['cw_user_id']."'");
account::logThis("Changed password","passwordchange",NULL);
}
При попытке сменить пароль выдаёт: "Не правильный старый пароль"
Подскажите что здесь может быть не так?
Таблица бд - account