dario Posted April 17, 2014 Share Posted April 17, 2014 I followed a tutorial for making a secure login system for my website, and now when i completed the tutorial it isnt working as it is supposed to. when i click the register page on my site it gives the error code Warning: mysqli::mysqli(): (HY000/1045): Access denied for user 'sec_user'@'localhost' (using password: YES) in C:\wamp\www\gip\includes\db_connect.php on line 3 im a newbie to php so please help me db_connect.php register.php Quote Link to comment Share on other sites More sharing options...
alphamoment Posted April 17, 2014 Share Posted April 17, 2014 Access denied for user 'sec_user'@'localhost' (using password: YES) in C:\wamp\www\gip\includes\db_connect.php on line 3 sec_user Does your MySQL have a user called "sec_user"? If not, then change it to root, that should work. A Post I recently made may help you; http://forums.phpfreaks.com/topic/287759-loginregister-help/?p=1476134 You can find it here. Quote Link to comment Share on other sites More sharing options...
dario Posted April 17, 2014 Author Share Posted April 17, 2014 yes i have a user called sec_user Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted April 17, 2014 Share Posted April 17, 2014 If you have created a MySQL user called sec_user then make sure you are using the correct password for that user for when you created it. Quote Link to comment Share on other sites More sharing options...
dario Posted April 17, 2014 Author Share Posted April 17, 2014 and where do i put that password then? Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted April 17, 2014 Share Posted April 17, 2014 Your scrpt gets the msyql username and password from psl-config.php. Make sure you have set the PASSWORD constant in that file to the correct password for sec_user username Quote Link to comment Share on other sites More sharing options...
dario Posted April 17, 2014 Author Share Posted April 17, 2014 well im a step further now i have another error Quote Link to comment Share on other sites More sharing options...
dario Posted April 17, 2014 Author Share Posted April 17, 2014 Fatal error: Call to undefined function openssl_random_pseudo_bytes() in C:\wamp\www\gip\includes\register.inc.php on line 52 Quote Link to comment Share on other sites More sharing options...
dario Posted April 17, 2014 Author Share Posted April 17, 2014 // TODO: // We'll also have to account for the situation where the user doesn't have // rights to do registration, by checking what type of user is attempting to // perform the operation. if (empty($error_msg)) { // Create a random salt $random_salt = hash('sha512', uniqid(openssl_random_pseudo_bytes(16), TRUE)); // Create salted password $password = hash('sha512', $password . $random_salt); // Insert the new user into the database if ($insert_stmt = $mysqli->prepare("INSERT INTO members (username, email, password, salt) VALUES (?, ?, ?, ?)")) { $insert_stmt->bind_param('ssss', $username, $email, $password, $random_salt); // Execute the prepared query. if (! $insert_stmt->execute()) { header('Location: ../error.php?err=Registration failure: INSERT'); } } header('Location: ./register_success.php'); } } ?> this is where the bug is but i cant really see it xs Quote Link to comment Share on other sites More sharing options...
dario Posted April 17, 2014 Author Share Posted April 17, 2014 line 52 is the one creating the random salt Quote Link to comment Share on other sites More sharing options...
Solution Ch0cu3r Posted April 17, 2014 Solution Share Posted April 17, 2014 You are getting that error because you do not have the openssl extension enabled. You need to open your php.ini and enable the openssl extension. You appear to be using WAMP. If I rememeber you can open the php.ini file from the wamp taskbar icon, by left clicking it and selecting PHP > php.ini now find the following line ;extension=php_openssl.dll and remove the semi-colon at the start of the line. Save the php.ini and restart Apache. Quote Link to comment Share on other sites More sharing options...
dario Posted April 17, 2014 Author Share Posted April 17, 2014 You are my hero!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.