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 "留言失败!";
        }
  • 相关阅读:
    P1439 【模板】最长公共子序列
    DP,入门???
    关于Eclipse在servlet中连接数据库时出现驱动加载失败的解决
    JSP学习(JavaBean)
    HTML随笔3
    CSS随笔3
    计算机网络随笔
    基本命令行操作1(java编译)
    Javascript随笔2(JQuery)
    Javascrip随笔1
  • 原文地址:https://www.cnblogs.com/jinshui/p/5630587.html
Copyright © 2011-2022 走看看