Skip to main content
Participant
October 6, 2015
Question

Update password

  • October 6, 2015
  • 2 replies
  • 491 views

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!!

    This topic has been closed for replies.

    2 replies

    Legend
    October 7, 2015

    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'");

    }

    ?>

    Nancy OShea
    Community Expert
    Community Expert
    October 6, 2015

    You might want to post this in the Coding Corner.

    Coding Corner

    Nancy O.

    Nancy O'Shea— Product User & Community Expert