For some reason, this form doesn't insert into my database.
Html
<form action="../php/register.php" method="post">
<div id ="personal-form">
<h4><b>Personal Details:</b></h4>
<hr>
<div class="form-group">
<label class="sr-only" for="first-name">First name</label>
First Name
<input type="text" name="firstname" placeholder=""
class="form-control" id="firstname">
<button type="submit" class="btn btn-next" id="submit">
Submit
</button>
</center>
</div>
</div>
</form>
php/register.php
<?php
include('connect.php');
if(isset($_POST["submit"])) {
$firstname = $_POST["firstname"];
$stmt = $conn->prepare("INSERT INTO storeowners (firstname) VALUES
(:firstname)");
$stmt->bindParam(':firstname', $firstname);
$stmt->execute();
header("location: next.php");
}
?>
This is connect.php
<?php
$servername = "localhost";
$username = "root";
$password = "";
try {
$conn = new PDO("mysql:host=$servername;dbname=blaza", $username,
$password);
//set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "success";
} catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}
?>
When I click on submit button, it shows the php/register.php page with the message success which is thesame message in the connect.php code if db connection was successful. I dont know where the problem is cause it doesnt store the firstname to the database and no error was given.
for="first-name"&id="firstname"do not match.</center>tag with no opening one (not a php issue but an issue)