$username = mysqli_real_escape_string($conn, $_POST['username']);
$password = mysqli_real_escape_string($conn, $_POST['password']);
$confirmPassword = mysqli_real_escape_string($conn, $_POST['confirmpassword']);
$email = mysqli_real_escape_string($conn, $_POST['email']);
$insertSQL = "INSERT INTO 'user' ('ID', 'Username', 'Password', 'Email') VALUES('".NULL."', '".$username."', '".$password."', '".$email."')";
if(mysqli_query($conn, $insertSQL));
{
echo "<script>window.open('../index.php', '_self')</script>";
}
mysqli_query returns true in the if statement, but nothing is being added to the database. I'm using mysqli to connect to my db:
$dbservername = "my_Server_Name";
$dbusername = "my_Username";
$dbpassword = "my_Password";
$dbname = "my_DB";
// Create connection
$conn = new mysqli($dbservername, $dbusername, $dbpassword, $dbname);
// Check connection
if ($conn->connect_error)
{
die("Connection failed: " . $conn->connect_error);
}
I believe the connection is fine because it has worked in other scenarios when pulling tables from the DB to check information, but seemingly will not work when I attempt to add VALUES into the db.
Here is the db as well:
CREATE TABLE `user` (
`ID` int(10) UNSIGNED NOT NULL,
`Username` varchar(31) NOT NULL,
`Password` varchar(31) NOT NULL,
`Email` varchar(63) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `user` (`ID`, `Username`, `Password`, `Email`) VALUES
(1, 'username', 'password', 'exampleEmail@example.com');