我正在使用所附的代码在MYSQL数据库的Users表中插入一条记录,该代码工作正常,但每次创建用户时它都会插入两条记录。我不确定为什么要在代码中插入一次(或者至少是这样)。也许有人遇到过类似的问题?
<?php
$username = $_GET["username"];
$password = $_GET["password"];
$con=mysqli_connect("localhost","pluginconnect","","UAPlugin");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_select_db($con,"UAPlugin");
$result = mysqli_query($con,"INSERT INTO UAPlugin_Login (username, password)
VALUES ('$username', '$password')");
$jsonResponse = array("UAPlugin" => array());
if(!$result)
{
die('Could not enter data: ' . mysql_error());
$jsonRow = array(
"success"=>"0",
"message"=>"Account Not Created");
array_push($jsonResponse["UAPlugin"],$jsonRow);
}
else
{
$jsonRow = array(
"success"=>"1",
"message"=>"Account Created");
array_push($jsonResponse["UAPlugin"],$jsonRow);
}
echo json_encode($jsonResponse);
?>