[英]PHP passing encrypted password by parameter
I pass encrypted password in the parameters of a function to connect to a database, but I don't know how to use it to connect to database? 我在函数的参数中传递了加密密码以连接到数据库,但是我不知道如何使用它来连接数据库?
function get_connectivity($pwd){
$host = "localhost";
$user = "root";
$pass = $pwd;
$database = "testing";
$db = new mysqli($host, $user, $pass, $database);
if ($db->connect_errno) {
return false;
exit();
}
$db->close();
return true;
}
I call it this way: 我这样称呼它:
get_connectivity(sha1("example"));
Is this even possible? 这有可能吗? Thanks.
谢谢。
Change to this. 改成这个。 It is already declared, just pass it to the connection.
它已被声明,只需将其传递给连接即可。
function get_connectivity($pwd){
$host = "localhost";
$user = "root";
$database = "testing";
$db = new mysqli($host, $user, $pwd, $database);
if ($db->connect_errno) {
return false;
exit();
}
$db->close();
return true;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.