So I'm creating a simple page and I want that my login and passwords to go to the DB now on the login form:
<form id="form_6de933" name="validate" action="insert.php" method="post" class="login-form narrow-cols">
I added action="insert.php" and on the insert.php file I tried to do this
<?php
$servername = "localhost";
$username = "xxx";
$password = "xxx";
$dbname = "xxx";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO nametable (username, password)
('$_POST[username]','$_POST[password]')";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
But when I click submit I get this
Parse error: syntax error, unexpected '{' in insert.php on line 10.
So can somone help me fix this error or I'm I doing something wrong?