• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Update password

Explorer ,
Oct 06, 2015 Oct 06, 2015

Copy link to clipboard

Copied

I've tried several variations but I can't get any of them to execute.

If someone can tell me what's wrong with this I'd be grateful -

~~~~~~~~~~~~~~~~~

      if ($stmt = $mysqli->prepare("UPDATE members (password, salt) VALUES (?,?) WHERE email = ?"))

      {

        $stmt->bind_param('sss', $newpassword,$random_salt,$email);

        // Execute the prepared query.

        $stmt->execute();

        header("Location: ../secure/changepass.php?success=1'");

      }

      else {

      header("Location: ../secure/changepass.php?passwordfailed=1'");

      }

~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Thanks!!

Views

428

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 06, 2015 Oct 06, 2015

Copy link to clipboard

Copied

You might want to post this in the Coding Corner.

Coding Corner

Nancy O.

Nancy O'Shea— Product User, Community Expert & Moderator

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 07, 2015 Oct 07, 2015

Copy link to clipboard

Copied

LATEST

You're using the wrong mysqli syntax to 'update' a database (see below, that should work). Obviously change the $newpassword, $random_salt and $email to whatever is getting that information.

<?php

// connect to database

$mysqli = new mysqli('localhost' , 'username , 'password' , 'database_name');

$stmt = $mysqli->prepare("UPDATE members SET password = ?, salt = ? WHERE email = ?");

if($stmt = $mysqli->prepare("UPDATE members SET password = ?, salt = ? WHERE email = ?")) {

$stmt->bind_param("sss", $newpassword, $random_salt, $email);

// set parameters and execute

$newpassword = "Pink";

$random_salt = "Elephant";

$email = "email_address.com";

$stmt->execute();

header("Location: ../secure/changepass.php?success=1'");

}

else {

header("Location: ../secure/changepass.php?passwordfailed=1'");

}

?>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines