**已关闭。**此问题为not reproducible or was caused by typos。当前不接受答案。
这个问题是由打字错误或无法再重现的问题引起的。虽然类似的问题在这里可能是on-topic,但这个问题的解决方式不太可能帮助未来的读者。
昨天关门了。
Improve this question
请帮我拿这个
致命错误:未捕获的错误:在C:\xampp\htdocs\final_program\php\loged_in中找不到类“mysqli_connect”。Copyright © 2018 - 2019 www.jsjsj.com All Rights Reserved版权所有
我尝试删除分号(;)以取消注解它:
extension=mysqli
但我的PHP代码仍然没有连接到我的数据库phpmyadmin它只显示此代码
致命错误:未捕获的错误:在C:\xampp\htdocs\final_program\php\loged_in中找不到类“mysqli_connect”。Copyright © 2018 - 2019 www.jsjsj.com All Rights Reserved版权所有
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "management";
$conn = new mysqli_connect($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if (isset($_POST['login'])) {
// Get username and password from form data and validate them
$username = $_POST['username'];
$password = $_POST['password'];
// Check if the username and password are correct
// In this example, we're using a MySQLi prepared statement to protect against SQL injection
$stmt = $conn->prepare("SELECT * FROM users WHERE username = ? AND password = ?");
$stmt->bind_param("ss", $username, $password);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows == 1) {
// If the user is authenticated, set the user's login status to true
// In this example, we're just using a session variable to store the login status
$_SESSION['logged_in'] = true;
}
}
if (isset($_SESSION['logged_in']) && $_SESSION['logged_in'] == true) {
// If the user is logged in, display the success container by changing the CSS display property
echo '<style>.success-container { display: block; }</style>';```
1条答案
按热度按时间9gm1akwq1#
没有
mysqli_connect
类,按照documentation,建立数据库连接是procedural风格。请比较(取自同一页的示例):
如果你想使用OOP,那么选择前者。