I'm trying to make a registration form. This form needs to add data to the database when the submit is clicked. it's not giving any errors or messages. this is my code, I hope someone can help me.
<body>
<form action="" method"post" class="form">
<div class="form-group1">
<label for="" >Username :</label>
<input type="text" class="form-control" name="username" id="tb-username" placeholder="Username">
</div>
<div class="form-group2">
<label for="" >Password :</label>
<input type="password" class="form-control" name="password" id="tb-password" placeholder="Password">
</div>
<button type="submit" class="btn btn-primary" id="btn-submit" name="register">Submit</button>
</form>
<?php
if(isset($_POST['register']))
{
if(isset($_POST['username'], $_POST['password']))
{
$username = $_POST['username'];
$password = $_POST['password'];
$link = mysqli_connect("localhost", "root", " ", "vbproject");
if(mysqli_connect_errno())
{
printf("Connect failed: %s\n", mysqli_connect_errno());
exit();
}
$sql = "INSERT INTO users (username, password)
VALUES('$username', '$password')";
mysqli_close($link);
}
}
?>
</body>