虽然请求在没有错误的情况下完成,但它不会在数据库中写入。 它连接到我检查过的数据库。
这是我的代码:
<?php
$json = json_decode(file_get_contents("config.json"), true);
$dbuser = $json['dbuser'];
$servername = $json['dbip'];
$dbpass = $json['dbpass'];
$dbname = $json['dbname'];
$password = $_GET['password'];
$email = $_GET['email'];
// Create connection
$conn = mysqli_connect($servername, $dbuser, $dbpass);
mysql_select_db( $dbname );
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO credentials (usermail, pass)
VALUES ($email, $password)";
?>
示例:http://localhost/php/database.php?email=random@mail.com&password=ilovestackoverflow
它没有做任何事情。如果您有任何想法,请
答案 0 :(得分:1)
你必须引用如下字符串:
$sql = "INSERT INTO credentials (usermail, pass)
VALUES ('$email', '$password')";