i'm using Xampp and when I run the php code its self it works fine, but when I connect html and php and then I click on submit button in html, the complete php code comes out.
Any idea, what I'm missing out?
THE HTML CODE
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form action="register.php" method="post">
<div>
<label for="firstname">Firstname</label>
<input type="text" name="firstname">
</div>
<div>
<label for="lastname">lastname</label>
<input type="text" name="lastname">
</div>
<button type="submit">submit</button>
</form>
</body>
</html
THE PHP CODE
<?php
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$conn = new mysqli('localhost', 'root', '', 'testt');
if($conn->connec_error) {
die ('connection failed : '.$conn->connect_error);
} else{
$stmt = $conn->prepare("insert into testtt(firstname, lastname) values(?,?)");
$stmt->bind_param("ss", $firstname, $lastname);
$stmt->execute();
echo "Registration succesfully...";
$stmt->close();
$conn->close();
}
?>