我正在尝试将登录数据输入到myPHPAdmin数据库中,但是似乎没有任何数据输入。
<?php
require_once "dbInfo.inc.php";
$firstName = $_POST['firstNameTextBox'];
$lastName = $_POST['lastNameTextBox'];
$phoneNum = $_POST['teleNumbBox'];
$email = $_POST['emailBox'];
$SIN = $_POST['SINNumBox'];
$password = $_POST['passTextBox'];
$conn = mysqli_connect($host, $username, $dbPassword);
if($conn->connect_error){
die("connection Failed: ". $conn->connect_error);
$connErrMsg = $conn->connect_error;
}
$succConn = "Successfuly Connected";
mysqli_select_db($conn, $database);
$sqlQuery = "INSERT INTO employee VALUES('$firstName', '$lastName', '$phoneNum', '$email',
'$SIN', '$password')";
if (mysqli_query($conn, $sqlQuery)) {
} else {
echo "Person Could not be added: " . $sqlQuery . "<br>" . mysqli_error($conn);
}
mysqli_query($conn, $sqlQuery);
$queryError = mysql_error($sqlQuery);
mysqli_close($conn);
session_start();
$_SESSION["firstName"] = $firstName;
$_SESSION["lastName"] = $lastName;
$_SESSION["teleNum"] = $phoneNum;
$_SESSION["email"] = $email;
$_SESSION["SINNum"] = $SIN;
$_SESSION["password"] = $password;
$_SESSION["queryError"] = $queryError;
$_SESSION["connErrMsg"] = $connErrMsg;
$_SESSION["succConn"] = $succConn;
header("Location: ../ViewAllEmployees.php");
exit();
?>
我知道表单中的数据是正确的,因为我已经回显了变量,并且我所有的错误消息一无所获。如果有人知道是什么原因导致我无法输入数据,请告诉我。
您将需要在phpMyAdmin目录中打开config.inc.php,并确保其设置如下:
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = '';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
请注意,'AllowNoPassword'必须设置为true