I am not using any Xampp or wampp, I have manually installed and configured all the software bellow:
apache
php
phpmyadmin
mysql
I even tested if the php is working correctly by creating a 'test.php' file in the "C:/Apache/htdocs" folder of apache and it was working properly.
Issue: I am creating registration form, I have attached the connect.php to index.html which are present inside the folder "C:/Apache/htdocs/Test" but the php code is not executing instead the content of .php file is displaying in the browser.
<?php
$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
$gender = $_POST['gender'];
$email = $_POST['email'];
$password = $_POST['password'];
$number = $_POST['number'];
// Database connection
$conn = new mysqli('localhost','root','abcdefg','test');
if($conn->connect_error){
echo "$conn->connect_error";
die("Connection Failed : ". $conn->connect_error);
} else {
$stmt = $conn->prepare("insert into registration(firstName, lastName, gender, email, password, number) values(?, ?, ?, ?, ?, ?)");
$stmt->bind_param("sssssi", $firstName, $lastName, $gender, $email, $password, $number);
$execval = $stmt->execute();
echo $execval;
echo "Registration successfully...";
$stmt->close();
$conn->close();
}
?>
connection in .html file:
<div class="panel-body">
<form action="connect.php" method="post">