add.php-Dateiinhalt
<?php
//Importieren Sie die Verbindungsdatenbankdatei
include ('conn.php');
//Erkennen Sie, ob der Benutzer die Schaltfläche sendet
if(isset($_POST[' einreichen'] ) {
$ ID = $ _ post ['ID'];
$ user = $ _ Post ['title']; insert into message(id,user,title,content,lastdate)values('','$user','$title','$content',now())";
mysqli_query($ conn,$sql);
// echo "<script>alert('Erfolgreich hinzufügen');history.go(-1)</script>";
echo"<script>alert('Nachricht erfolgreich' );location.href= 'liu.html'</script>";
}else{
echo "Fehlgeschlagen";
}
?>
liu.html-Inhalt
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>第一个MYSQL查询留言本</title& gt;
< 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& lt;/small>
</h1>
</div>
Klicken Sie auf das Popup-Bearbeitungsfeld, um den Block zu sortieren. tn-large" href="#" >Mehr anzeigen»</a> ;
<table class="table table-bordered">
<thead>
<tr>
< th>
ID
</th>
<th> 名字
</th> ;
</th>
标题
<th>
内容
</th> < /tr>
</thead>
<tbody>
<tr class= "success">
<td>
ID
</td>
<td>
TB – Monatlich
</td> 01/04/2012
</td>
<td> Genehmigt
</td>
</tr>
</tbody>
</table>
<form action="add.php" method="post">
<fieldset>
<legend>表单项</legend>
<label>名字</label><input type="text" name="user" erforderlich/>
<label>标题</label><input type="text" name="title" erforderlich/>
& Lt;<button type="submit" class="btn" name="submith">Submit</button>
/div>
</div>
你确定你的sql语句没有写错么 $sql="insert into message(id,user,title,content,lastdate)values('','$user','$title','$content',now())";
values(" 这里错了吧
你这样写肯定会到else的。 不提交 ,$_POST['submit'] 肯定没有内容。
是添加失败吗????你看下 SQL语句 单引号是不解析变量的 其它的暂时没能从代码上看得出来
有大神帮忙看下么
是直接就提示失败了是么?