Jump to content

Recommended Posts

Guest Joseppi83
Posted (edited)

So, I have followed the instructions to a 'T,' yet I get a notice after I update the password.

I thought I might be missing something from the videos, so I cut what I typed out and copied and pasted the source code files for the video section in it, but the exact same notice rendered in the browser.

Any idea what's up with the notice?

Does it have to do with deprecated code from previous versions, since Ben's browser was not rendering the same notice?

else
		{
			// insert into database
			if ($stmt = $mysqli->prepare("UPDATE members SET password = ? WHERE id = ?"))
			{
				$stmt->bind_param("ss", md5($input['pass'] . $config['salt']), $_SESSION['id']);
				$stmt->execute();
				$stmt->close();

				// add alert and clear form values
				$error['alert'] = 'Password updated successfully!';
				$input['current_pass'] = '';
				$input['pass'] = '';
				$input['pass2'] = '';

				// show form
				include('views/v_password.php');
			}
			else
			{
				echo "ERROR: Could not prepare MySQLi statement.";
			}
		}

            

PHPLogin.png

Edited by Joseppi83
Posted

Hi,

I don't know what line is line 106, but look at this line:

$stmt->bind_param("ss", md5($input['pass'] . $config['salt']), $_SESSION['id']);

It could be he is trying to pass this into the array:

md5($input['pass']

So instead, assign to a variable and pass that. So do something like:

$salted = md5($input['pass'];

And then:

$stmt->bind_param("ss", $salted . $config['salt']), $_SESSION['id']);

The md5 hash function is altering the stat of $input['pass'], so that could be causing the notice to appear. 

I haven't looked at what Ben did in that video, but he may have just turned off error_reporting for PHP. 

Hope that helps,

Stef

 

  • 2 weeks later...
Guest Joseppi83
Posted

Breaking it up into smaller chunks as variables like that fixed it.

Merci.

  • 1 year later...
Posted

I've been having some kind of problem with this too. This is the code I used based on Bens tutorial and Stephans update.            

            $salted = md5($input['pass']);
            $password = ($salted . $config['salt']);
            $stmt->bind_param("ss", $input['user'], $password);
            $stmt->execute();
            $stmt->store_result();

 

It still isn't working. It just says all usernames and passwords are incorrect, even the correct "admin" "admin". When I hard code in the correct details it processes it fine and goes to the members.php page. So it's connecting to the database correctly and the IF statements to check the input to the database are also working correctly. Any help would be hugely appreciated. 

 

SD

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...