写了个简易留言板,提交留言后,页面就会转向做后台处理的php页面,因为提交后页面跳转到php页面后就一片白了,不雅观。
如何使他停留在当前页面?求指点

解决方案 »

  1.   

    你在后台处理的php页面最后再转向回到原页面即可。
      

  2.   

    1.直接提交到本页处理
    2.传到处理页的时候加一个参数表明跳回到哪里,处理完跳回
    3.ajax
      

  3.   

    不用本页处理就必须得用AJAX请求!达到无刷新提交留言!
      

  4.   

    我来回答。几种方法。
    1.直接提交到本页处理
    2.提交到其他页面处理,处理完后再返回。
    要想实现局部刷新效果。
    1.ajax  复杂些
    2.嵌入iframe直接提交到本页处理我有完整的php源码,我只列出php代码,参考下。<?php
    function ToHtml($text)
    {
    $text=htmlspecialchars($text);
    $text=trim($text);
    $text=str_replace("\r","",$text);
    $text=str_replace("\n","<br/>",$text);
    $text=str_replace(" ","&nbsp;",$text);
    return $text;
    }
    ?>
    <?php
    $action=$_REQUEST[action];
    $page=$_REQUEST[curPage];
    $check1=$_REQUEST[check1];
    $name=$_REQUEST[name];
    $content=$_REQUEST[content];
    $ip=$_SERVER["REMOTE_ADDR"];if(empty($page))
    {
    $page=1;
    }
    if (!empty($check1))
    {
    $name="匿名网友";
    }
    if (empty($content))
    {
    $action="list";
    }
    else if(empty($name))
    {
    $action="list";
    }
    else
    {
    $action="submit";
    }
    if($action=="submit")
    {
    $conn=mysql_connect("localhost","root","root")or die("error:".mysql_error());
    mysql_select_db("udb_name");
    mysql_query("set names gb2312");
    $sql="insert into bbs(gst_user,gst_content,gst_ip) values('".$name."','".$content."','".$ip."')";
    mysql_query($sql);
    }
    $action="list";
    $conn=mysql_connect("localhost","root","root")or die("error:".mysql_error());
    mysql_select_db("udb_name");
    mysql_query("set names gb2312");
    $pagesize=10;
    $sql="select * from bbs order by gst_time desc";
    $_result=mysql_query($sql);
    $total=mysql_num_rows($_result);
    $pageCount=1+(int)(($total-1)/$pagesize);
    $result=mysql_query($sql." limit ".$pagesize*($page-1).",".$pagesize,$conn);
    ?>
    <div style="font-family:微软雅黑;width: 810px;height: 147px;text-align: left; overflow: visible; background-color: white;" id="bbs">
     <span style="font-size: 11pt"><strong>首页>留言板<br/>
    </strong></span>
    <form action="index.php" method="post">
    <textarea name="content" style="width: 800px; height: 69px; overflow: auto;"></textarea><br/>
    <input id="Submit1" type="submit" value="留言" style="width: 51px; color: white; background-color: #ff8901" />&nbsp;
    <input id="check1" name="check1" type="checkbox" value="on" />
    匿名 &nbsp; &nbsp; &nbsp; 
    你的姓名<input id="name" name="name" style="left: 7px; width: 110px;position: relative; top: 2px" type="text" />
    </form>
    <?php
    if($pageCount==1)
    {?>
    首页&nbsp;&nbsp;&nbsp;上一页&nbsp;&nbsp;&nbsp;下一页&nbsp;&nbsp;&nbsp;尾页
    <?php
    }
    else if($page<=1)
    {?>
    首页&nbsp;&nbsp;&nbsp;上一页&nbsp;&nbsp;&nbsp;
    <a href=<?php echo $curUrl."?action=".$action."&curPage=".($page+1);?>>下一页</a>&nbsp;&nbsp;&nbsp;
    <a href=<?php echo $curUrl."?action=".$action."&curPage=".$pageCount;?>>尾页</a>
    <?php
    }
    else if($page>=$pageCount)
    {?>
    <a href=<?php echo $curUrl."?action=".$action."&curPage=1";?>>首页</a>&nbsp;&nbsp;&nbsp;
    <a href=<?php echo $curUrl."?action=".$action."&curPage=".($page-1);?>>上一页</a>
    &nbsp;&nbsp;&nbsp;下一页&nbsp;&nbsp;&nbsp;尾页
    <?php
    }
    else
    {?>
    <a href=<?php echo $curUrl."?action=".$action."&curPage=1";?>>首页</a>&nbsp;&nbsp;&nbsp;
    <a href=<?php echo $curUrl."?action=".$action."&curPage=".($page-1);?>>上一页</a>&nbsp;&nbsp;&nbsp;
    <a href=<?php echo $curUrl."?action=".$action."&curPage=".($page+1);?>>下一页</a>&nbsp;&nbsp;&nbsp;
    <a href=<?php echo $curUrl."?action=".$action."&curPage=".$pageCount;?>>尾页</a>
    <?php
    }
    echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".$page."/".$pageCount;
    while ($info=mysql_fetch_row($result))
    {
    echo "<hr color=gray size=1>";
    echo "<span style=color:gray;font-size:14px>".ToHtml($info[1])."&nbsp;&nbsp;&nbsp;".ToHtml($info[3])."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".ToHtml($info[4])."</span><br/>";
    echo "<span style=color:black;font-size:16px>".ToHtml($info[2])."</span>";
    }
    echo "</div>";
    ?>
      

  5.   

    把表建好可是可以直接用的啊。
    表bbs的内容为  id  username content ip time.