close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Updating a password hash field - stopped working

Thread began 1/30/2023 7:47 am by sandy170299 | Last modified 2/04/2023 1:52 pm by Ray Borduin | 177 views | 4 replies |

sandy170299

Updating a password hash field - stopped working

For some reason, this stopped working. Using the update MySQLi server behavior, I have the following code:

<?php
if (isset($_POST["Update"]) || isset($_POST["Update_x"])) {
$password = $_POST['user_password'];
$hash = password_hash($password, PASSWORD_DEFAULT);
$UpdateQuery = new WA_MySQLi_Query($numdb);
$UpdateQuery->Action = "update";
$UpdateQuery->Table = "users";
$UpdateQuery->bindColumn("acct_number", "i", "".((isset($_POST["acct_number"]))?$_POST["acct_number"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("balance", "i", "".((isset($_POST["balance"]))?$_POST["balance"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("line_of_credit", "i", "".((isset($_POST["line_of_credit"]))?$_POST["line_of_credit"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("user_name", "s", "".((isset($_POST["user_name"]))?$_POST["user_name"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("user_password_hash", "s", "#hash", "WA_IGNORE");
$UpdateQuery->bindColumn("user_email", "s", "".((isset($_POST["user_email"]))?$_POST["user_email"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("user_active", "i", "".((isset($_POST["user_active"]))?$_POST["user_active"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("referrer", "i", "".((isset($_POST["referrer"]))?$_POST["referrer"]:"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("analogcode", "i", "", "WA_DEFAULT");
$UpdateQuery->bindColumn("notes", "s", "".((isset($_POST["notes"]))?$_POST["notes"]:"") ."", "WA_DEFAULT");
$UpdateQuery->addFilter("user_id", "=", "i", "".($WADAusers_update->getColumnVal("user_id")) ."");
$UpdateQuery->execute();
$UpdateGoTo = "accounts.php";
if (function_exists("rel2abs")) $UpdateGoTo = $UpdateGoTo?rel2abs($UpdateGoTo,dirname(__FILE__)):"";
$UpdateQuery->redirect($UpdateGoTo);
}
?>

If the password is not physically changed in the form field, I want it to ignore it, so I'm using WA_IGNORE to update that field. It's not working. Each time I try to log in after changing the password, I get a password failed page, which I created if the login didn't work. What is the correct syntax I should be using for this field?

Thank you.

Sign in to reply to this post

Ray BorduinWebAssist

I think this line:

$UpdateQuery->bindColumn("user_password_hash", "s", "#hash", "WA_IGNORE");


should be:

$UpdateQuery->bindColumn("user_password_hash", "s", "".((!empty($_POST["password"]))?password_hash($_POST["password"]):"") ."", "WA_IGNORE");
Sign in to reply to this post
Did this help? Tips are appreciated...

sandy170299

Thank you!

Sign in to reply to this post

sandy170299

It's not working. If I update other fields, and ignore the password, it stays the same, so it is being ignored. But if I change it, even to something like 12345, it doesn't work when I log out and then try to log back in. I'm always redirected to the failed.php page.

Sign in to reply to this post

Ray BorduinWebAssist

Is your password supposed to be a hash in the database? Can I see a copy of your login page? Maybe it should just be:

php:
$UpdateQuery->bindColumn("user_password_hash", "s", "".((!empty($_POST["password"]))?$_POST["password"]:"") ."", "WA_IGNORE");
Sign in to reply to this post
Did this help? Tips are appreciated...

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...