刚学习php,做一个留言练习。。提交表单,然后入库,接下来怎么让刚回复内容显示到网页上。。这个思路我搞不清楚,希望大家给我讲讲。。代码如下:
feedback.php:
<html>
<head>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/globle.js"></script>
<style type="text/css">
*{margin: 0px; padding: 0px;list-style:none;
}
body{
text-algin:center;
margin:0 auto;
}
#container{
width:960px;
height:1000px;
text-algin:center;
margin:0 auto;
padding:50px 0px 0px 0px;
background:#d6e3f0;
}
#content{
float:left;
margin-top:10px;
margin-left:300px;
height:275px;
font-size:12px;
}
#feed_button{
float:left;
margin:10px 0px 0px 130px;
}
</style>
</head>
<body>
<div id="container">
<div id="content">
<p><label>姓名:</label><br/><input id="feed_text" type="text" name="feed_text" size="20" /></p>
<label>内容:</label><br/>
<textarea id="feed_content" rows="10" cols="50" name="feed_content" ></textarea><br/>
<input id="feed_button" type="submit" style="width:100px; height:30px">
</div>
</div>
</body>
</html>feed_ok.php:
<?php
$fb_title= $_POST["name"];
$fb_content= $_POST['feed_content'];
//echo $fb_title;
$link= mysql_connect("localhost","root","yang") or die(mysql_error());
mysql_select_db('feedback');
$sql= mysql_query("insert into fd_table values('$fb_title','$fb_content')");
echo $sql? "留言成功" : no;

?>
globle.js:
$(document).ready(function(){
$("#feed_button").click(function(){
var feed_text= $('#feed_text').val();
var feed_content= $('#feed_content').val();
if( feed_text=="" || feed_content=="" ){
alert("姓名和留言内容不能为空");
return false;
}
$.post('feed_ok.php',{"name": feed_text,"feed_content":feed_content},function(data){
if(data){
return true;

}
})
})
})

解决方案 »

  1.   

    header("Location: your display url"));
      

  2.   

    做一个跳转。。提交到一个php页面后那个php页面使用一个跳转,header("Location: your display url"));跳转到你要显示的页面,相当于刷新一次页面
    -------------------------------签名分割线--------------------------------
    慢慢学习,菜鸟也能变老鸟