Hello dear community members,
I'm having issues inserting successfully into a little database I made. I'm trying to code a login using PHP to insert into the database directly. Here's the database code:
create table login (
id INT PRIMARY KEY AUTO_INCREMENT,
username VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
vorname VARCHAR (255) NOT NULL,
nachname VARCHAR (255) NOT NULL,
email VARCHAR (255) NOT NULL);
And here's my PHP code:
$link = mysqli_connect("localhost", "root", "", "projektmanagement");
// Check connection
if ($link === false) {
die("ERROR: Could not connect. " . mysqli_connect_error());
} else {
print "<h3>Connected!</h3>";
}
// Attempt insert query execution
$sql = "INSERT INTO login (username, password, vorname, nachname, email) VALUES ('Username', 'Password', 'Vorname', 'Nachname' 'peterparker@mail.com')";
if (mysqli_query($link, $sql)) {
echo "Records inserted successfully.";
} else {
echo "ERROR: Could not execute $sql. " . mysqli_error($link);
}
I have looked through countless threads, seeing if I miscounted or forgot a value, but I can't seem to find the mistake.
Any help would be greatly appreciated!
- Thomas