Jump to content

PHP Login System


Guest Joseppi83

Recommended Posts

Guest Joseppi83

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
Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 year later...

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...