I'm a beginner and I am trying to learn PHP and SQL. I've written the code below so I can insert data into my database but I do not understand why it is not working. It loads and everything but when I click on the "Sign Up" button, it does nothing. Can someone help me figure it out?
<?php include 'config.php'; ?>
<?php
if(isset($_POST['submit'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$query = "INSERT INTO users1(username,password) VALUES ('$username','$password')";
$result = mysqli_query($con,$query) or die ("problem inserting new product into database");
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Sign Up</title>
<style>
button {
text-align:center;
color: gray;
}
</style>
</head>
<body>
<h2>Sign Up</h2>
<h3>Enter your data to register</h3>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="POST">
<label class="user-name">Username</label><input type="text" name="username" placeholder="Enter your username" autofocus required"><br><br>
<label class="pass-word"> Password: </label><input type="password" name="pass" class="info" placeholder="Enter your Password" required ><br><br>
<button class="lbutton" type="submit" value="Submit">Sign Up</button>
<p>Already registered? <a href="login2.php">Login</a></p>
</body>
</html>