Okay, I can explain the latter of your problem, I still can't explain the first part (yet).
So let's start with the latter, when the passwords are the same. Here is your existing code:
PHP Code:
<?php
// display errors, warnings, and notices
ini_set("display_errors", true);
error_reporting(E_ALL);
// configuration
require("../includes/constants.php");
require("../includes/functions.php");
// if form was submitted
if(isset($_POST["submit"]))
{
if (empty($_POST["password"]))
apologize("Please enter password.");
if ($_POST["password"] != $_POST["confirmation"])
apologize("Passwords do not match!");
$result = query("UPDATE users SET hash = ? WHERE id = ?", crypt($_POST["password"], $_SESSION["resetmemberid"]));
unset($_SESSION["resetmemberid"]);
if($result===false)
{
apologize("Could not register. Please retry.");
}
else
{
$rows = query("SELECT id FROM users WHERE hash = ?", crypt($_POST["password"]));
$id = $rows[0]["id"];
// remember that user's now logged in by storing user's ID in session
$_SESSION["id"]= $rows[0]["id"];
// redirect to portfolio
redirect("index.php");
}
}
else
{
// else render form
render("reset_form.php", ["title" => "Register"]);
}
?>
I want to draw focus on
PHP Code:
$result = query("UPDATE users SET hash = ? WHERE id = ?", crypt($_POST["password"], $_SESSION["resetmemberid"]));
Look at your number of arguments, you are missing one. I believe you meant to use
PHP Code:
$result = query("UPDATE users SET hash = ? WHERE id = ?", crypt($_POST["password"], $_SESSION["resetmemberid"]), $_SESSION["resetmemberid"]);
However, if you are not using a salt with crypt, then you'll want to use:
PHP Code:
$result = query("UPDATE users SET hash = ? WHERE id = ?", crypt($_POST["password"]), $_SESSION["resetmemberid"]);
Bookmarks