form code:
<html>
<body>
<?php include('header.php'); ?>
<form action="contact_db.php" action ="get">
Name :<input type="text" name="name" /> <br/>;
Email :<input type="text" name="email" /><br/>;
Message :<textarea name="mytextarea" rows="10" cols="40"> </textarea>;
<input type="submit" name="submit" value="Submit"/>
</form>
<?php include('footer.php'); ?>
</body>
</html>
database code:
<?php
echo "hello";
include('dbconnect.php');
$stmt = $mysqli->prepare("insert into book_project.contact_table(name,email,message) values (?,?,?)");
if($_SERVER['REQUEST_METHOD'] == 'GET'){
if(!empty($_GET['name']) && !empty($_GET['email'])){
var_dump($_GET);
$stmt -> bind_param('sss',$name,$email,$mytextarea);
echo $name;
$stmt ->execute();
$stmt -> close();
echo "Thank you for contacting Spring book store";
include('home.php');
}
else{
echo "Kindly provide your name and email";
include('home.php');
}
}
?>
the post gets posted correctly, its working fine. But data is not getting inserted in database. could not understand the issue here. Do not know how to track the error in the code. its not displaying any error and the rows are empty.