0

Hello, if any body can help me , why in the code bello the results is always null or 0?
because when i want to change the password it always shows me this message "The current password you entered is not correct!"

<?php

@session_start();
include("./pg_connect/pgdb.class.php");
$db = new PQDatabase();

// Check if current password is correct
$sql = "SELECT * FROM telecom.users WHERE username = '" . $_GET["u"] . "' AND password = '" . md5($_POST['current_pwd']) . "'";
$result = $db->getNumberOfRows($db->query($sql));
if ($result == null || $result == 0)
{
    echo "{success: false, msg: 'The current password you entered is not correct!'}";
}
elseif ($_POST['new_pwd'] != $_POST['retype_pwd'])
{
    echo "{success: false, msg: 'The new password and the retyped password are not identical!'}";
}
else
{
    $db->query ("UPDATE telecom.users SET password = '" . md5($_POST['new_pwd']) . "' WHERE username = '" . $_SESSION["u"] . "'");
    echo "{success: true, msg: 'The password was changed successfully!'}";
}

?>

2
Contributors
2
Replies
15
Views
8 Months
Discussion Span
Last Post by iso_1
0

What is the PQDatabase class? Does it automatically connect? Add error handling, it might be a connection error or something else database related.

0

thank you , I have resolved it. The problem was in if condition.

Regards

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.