add.php file content
<?php
//Import the connection database file
include ('conn.php');
//Check whether the user Submit button
if(isset($_POST['submit'])){
- $title=$_POST['title'];
$content=$_POST['content'];
$sql="insert into message(id,user,title,content,lastdate)values('' ,'$user','$title','$content',now())";
mysqli_query($conn,$sql);
// echo "<script>alert('Added successfully ');history.go(-1)</script>";
echo"<script>alert('Message successful');location.href='liu.html'</script>";
}else{
echo "Failed";
}
?>
##liu.html content
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>第一个MYSQL查询留言本</title>
<script type="text/javascript" src="http://www.francescomalagrino.com/BootstrapPageGenerator/3/js/jquery-2.0.0.min.js"></script>
<script type="text/javascript" src="http://www.francescomalagrino.com/BootstrapPageGenerator/3/js/jquery-ui"></script>
<link href="http://www.francescomalagrino.com/BootstrapPageGenerator/3/css/bootstrap-combined.min.css" rel="stylesheet" media="screen">
<script type="text/javascript" src="http://www.francescomalagrino.com/BootstrapPageGenerator/3/js/bootstrap.min.js"></script>
<?php include ("add.php")?>
</head>
<body>
<?php include ("add.php")?>
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<div class="page-header">
<h1>
第一个MYSQL查询留言本 <small>V1.0</small>
</h1>
</div>: A visual layout template, you can click on the text in the template to modify, or click on the pop-up edit box to modify the rich text. Drag the block to sort. ;
;
<table class="table table-bordered">
<thead>
<tr>
<th>
ID
</th>
<th>
名字
</th>
<th>
标题
</th>
<th>
内容
</th>
</tr>
</thead>
<tbody>
<tr class="success">
<td>
ID
</td>
<td>
TB - Monthly
</td>
<td>
01/04/2012
</td>
<td>
Approved
</td>
</tr>
</tbody>
</table>
<form action="add.php" method="post">
<fieldset>
<legend>表单项</legend>
<label>名字</label><input type="text" name="user" required/>
<label>标题</label><input type="text" name="title" required/>
<label>留言内容</label><textarea name="content" rows="5" cols="30"></textarea>
<hr>
<button type="submit" class="btn" name="submith">Submit</button>
</div>
</div>
</body>
</html>
Question: That’s right, I didn’t feel like I had gone through the submission yet, but then I got to else
Are you sure your sql statement is correct $sql="insert into message(id,user,title,content,lastdate)values('','$user','$title','$content' ,now())";
values(" Is this wrong?
You will definitely come to Else. Do not submit, $ _ Post ['Submit'] must have no content.
Did the addition fail? ? ? ? Look at the SQL statement. Single quotes do not parse variables. Others cannot be seen from the code for the time being.
Can anyone help me check it out?
Is it a direct prompt of failure?