zoukankan      html  css  js  c++  java
  • 案例:简单留言板

    主页代码:

    <style type="text/css">
    *{
        margin:0px;
        padding:0px;
        }
    
    #a{
        margin:10px auto;
        width:300px;
        height:100px;
        }
    #b{
        border:#000 1px solid;
        width:300px;
        height:100px;
        margin:10px auto;
        }
    #aa{
        width:300px;
        height:100px;
        }
    </style>
    </head>
    
    <body>
    <br />
    <br />
    <br />
    <h1 align="center">留言板</h1>
    <div id="b">
    <?php
    session_start();
    include ("../DBDA.php");
    $dx=new DBDA();
    $sql="select * from liuyan where uid='{$_SESSION['uid']}'";
    $attr=$dx->Query($sql);
    foreach($attr as $v)
    {
        echo "<div><span>留言者:{$v[1]}</span>
        <span>留言信息:{$v[2]}</span>
        <span>留言时间:{$v[3]}</span>
        </div>";
    }
    ?>
    </div>
    <div id="a">
    <form action="chuli.php" method="post">
    请输入留言:<input type="text" id="aa" name="text"/>
    <input type="submit" value="提交"/>
    </form>
    </div>
    </body>

    处理页面:

    <?php
    session_start();
    $_SESSION["uid"]="yonh";
    include ("../DBDA.php");
    $text=$_POST["text"];
    $uid=$_SESSION["uid"];
    $time=date("y-m-d H:i:s");
    $dx=new DBDA();
    $sql="insert into liuyan values('','{$uid}','{$text}','{$time}')";
    //除了bool型和数字型不加'',都加''
    $re=$dx->Query($sql,0);
    if($re)
    {
        header("location:test.php");
        }
    else
    {
        echo "留言失败!";
        }
  • 相关阅读:
    Hdu 3666 THE MATRIX PROBLEM(差分约束)
    POJ1201Intervals(差分约束系统)
    hdu3440 House Man 【差分约束系统】
    使用字符流读写数据
    使用带有缓冲的字节流读写数据
    使用字节流读写数据
    字符、字节与编码
    Java IO简介
    文件的简单读写
    遍历文件夹
  • 原文地址:https://www.cnblogs.com/jinshui/p/5630587.html
Copyright © 2011-2022 走看看