Hello,
I have just attempted to update my database login page to MySQLi and also use prepared statements but upon submitting a form I receive the error "Access denied for user 'admin'@'localhost' (using password: NO)".
I have been researching this before posting this here but have only come across sites detailing switching server root credentials, etc - I am using a professional hosting site which I pay for (I am not running this on a server on my machine).
I have never received this error message before and I am using the same login credentials as always.
The new code is below.
Any help in the right direction or explanation would be greatly appreciated.
Thank you,
Matthew
`
<?php
$serverName = "localhost";
$userName = "********";
$password = "********";
$dbName = "********";
// Create connection
$conn = new mysqli($serverName, $userName, $password, $dbName);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Prepare and bind
$stmt = $conn->prepare("INSERT INTO Table4 (userName, birthYear, email, password, countries, state, city, zip, company, manager1, manager2) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->bind_param("sisssssisss", $userName, $birthYear, $email, $password, $countries, $state, $city, $zip, $company, $manager1, $manager2 );
$userName = $_POST['user'];
$birthYear = $_POST['birthYear'];
$email = $_POST['email'];
$password = $_POST['pass'];
$countries = $_POST ['countries'];
$state = $_POST ['state'];
$city = $_POST['city'];
$zip = $_POST['zip'];
$company = $_POST ['company'];
$manager1 = $_POST ['manager1'];
$manager2 = $_POST ['manager2'];
$stmt->execute();
echo "Thank you for registering - New records created successfully!";
$stmt->close();
$conn->close();
?>
`