I am using Xampp, I cant figure out why the php code is giving me an error. I have added my form and php code. The page goes into a 405 error as soon as I submit the form.
index.html
<body>
<div class="container">
<h2>5.3.3</h2>
<form action="connect.php" method="post">
<!--<div class="year">
Date of implementation: <br> <br><input type="date" class="inputfield" name="Date_of_implementation" >
</div>-->
<div class="name">
Name of the event/ activity: <br><br> <input type="text" class="inputfield" name="ename" >
</div>
<div class="student">
Name of the student participated: <br> <br><input type="text" class="inputfield" name="name" >
</div>
<input type="submit" class="btnn">
</form>
</div>
connect.php
```
<?php
$name = $_POST['name'];
$ename = $_POST['ename'];
// Database connection
$conn = new mysqli('localhost','root','','testnew');
if($conn->connect_error){
echo "$conn->connect_error";
die("Connection Failed : ". $conn->connect_error);
} else {
$stmt = $conn->prepare("insert into testtable(name,ename) values(?, ?)");
$stmt->bind_param("ss", $name, $ename);
$execval = $stmt->execute();
echo $execval;
echo "Registration successfully...";
$stmt->close();
$conn->close();
}
?>
source https://stackoverflow.com/questions/71630739/i-am-getting-an-405-error-when-i-execute-this-php-code-what-can-be-the-problem
No comments:
Post a Comment