0

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">
CodingNinja
  • 109
  • 6
  • 2
    Can you try with change index.html to index.php ? – Omar May 09 '21 at 09:19
  • You tested if PHP is working in the `htdocs` folder, but it seems that it does not work in your `htdocs/Test` folder. This would be a configuration error in your `apache`. – Luuk May 09 '21 at 09:25
  • Do you have any idea where might the configuration went wrong?, https://youtu.be/cm5L2EXA_t4 the link i followed for configuration. – CodingNinja May 09 '21 at 09:34
  • I have even tried keeping both .html and .php file in htdocs itself and still facing the same issue. – CodingNinja May 09 '21 at 09:51
  • 1
    changing index.html to index.php worked, you saved my day :) @OmarFaruque – CodingNinja May 09 '21 at 10:22

1 Answers1

-2

It appears that the document for the apache does not have any php integration or the php service is not running in that specific directory.