I am trying to insert data in the database but it is neither working nor showing the error
below is the form
<form id="RegForm" action= "reglogic.php" method= "POST">
<input type="text" name= "firstname" placeholder="firstname" required>
<input type="text" name= "lastname" placeholder="lastname" required>
<input type="text" name= "username" placeholder="username" required>
<input type="email" name= "email" placeholder="email" required>
<input type="password" name= "password" placeholder="password" required>
<button type="submit" name="submit" class="btn">Register</button>
</form>
the php logic
<?php
include "../database/connexion.php";
if(isset($_POST['submit']){
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$username = $_POST['username'];
$email = $_POST['email'];
$password = $_POST['password'];
$hashpassword = md5($password);
$role = 2;
$sql = "INSERT INTO users (first_namse, last_name, username, email, password, role_ID) VALUES ('$firstname', '$lastname', '$username', '$email', '$hashpassword', '$role')";
if(mysqli_query($conn, $sql)) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
mysqli_close($conn);
}
?>
connection
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "techmarket";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if ($conn === false) {
die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully";
?>
And the only output I get is this one
" . mysqli_error($conn); } mysqli_close($conn); } ?>
Please highlight me on this
I try all the possibility even putting the connection in the same page