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');
}
}
?>
帖子发布正确,工作正常。但是数据没有插入数据库中。在这里无法理解这个问题。不知道如何跟踪代码中的错误。 它没有显示任何错误,行是空的。