亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Tableau de messages du didacticiel de développement du forum de discussion PHP terminé

fichier conn.php

<?php
$conn = @ mysql_connect("localhost", "root", "123456789") or die("數(shù)據(jù)庫鏈接錯誤");
mysql_select_db("bbs", $conn);
mysql_query("set names 'utf8'"); //使用utf-8中文編碼;
?>

fichier add.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link href="css.css" rel="stylesheet" type="text/css">
    <title>Title</title>
    <?php include ("add.php")?>
</head>
<script>
    function CheckPost() {
        if(myform.user.value=="")
        {
            alert("請?zhí)顚懹脩?quot;);
            myform.user.focus();
            return false;
        }
        if (myform.title.value.length<5)
        {
            alert("標(biāo)題不能少于5個字符");
            myform.title.focus();
        return false;
        }
        if (myform.content.value=="")
        {
            alert("內(nèi)容不能為空");
            myform.content.focus();
            return false;
        }
    }
</script>
<body>
<b> <a href="list.php">瀏覽留言</a>  </b>
<hr size=1>
<form action="add.php" method="post" name="myform" onsubmit="return CheckPost();">
    用戶:<input type="text" size="10" name="user"/><br>
    標(biāo)題:<input type="text" name="title" /><br>
    內(nèi)容:<textarea name="content"></textarea><br>
    <input type="submit" name="submit" value="發(fā)布留言" />
</form>
</body>
</html>

fichier css.css

td {
   line-height: 16pt;
   font-size: 10pt;
   font-family: "Verdana", "Arial", "Helvetica", "sans-serif";
}
a:link {
   text-decoration: none;
   color: #000000;
}
body {
   font-size: 10pt;
   line-height: 13pt;
   background-color: #ECF5FF;
}
textarea {
   font-size: 8pt;
   font-family: "Verdana", "Arial", "Helvetica", "sans-serif";
   border: 1px solid #999999;
   padding: 5px;
}
form {
   margin: 0px;
   padding: 0px;
}
.textdrow {
   color:#666666;
   filter: DropShadow(Color=white, OffX=1, OffY=1, Positive=1);
}
.p {
   text-indent: 24px;
}


add.php

<?php
include ("conn.php");
if ($_POST['submit']){
  $sql="insert into message(id,user,title,content,lastdate) ".
        "values ('','$_POST[user]','$_POST[title]','$_POST[content]',now())";
    mysql_query($sql);
    echo "<script>alert('添加成功');history.go(-1)</script>";
}
?>

fichier list.php

<!DOCTYPE html>
<html lang="utf-8">
<head>
        <link href="css.css" rel="stylesheet" type="text/css">
</head>
<?php
include ("conn.php");
?>
<table width=500 border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#add3ef" >
    <?php
 $sql="select * from message order by id desc";
 $query=mysql_query($sql);
 while($row=mysql_fetch_array($query)){  ?>
 <tr bgcolor="#eff3ff">
            <td><font color="red">標(biāo)題:</font><?php echo $row['title'];?> <font color="red">用戶:</font><?php echo $row['user'];?><div align="right"><a href="del.php?id=<?php echo $row['id'];?>">刪除</a></div></td>
        </tr>
        <tr bgColor="#ffffff">
            <td>發(fā)表內(nèi)容:<?php echo $row['content'];?></td>
        </tr>
        <tr bgColor="#ffffff">
            <td><div align="right">時間:<?php echo $row['lastdate'];?></td>
        </tr>
    <?php } ?>
 <tr bgcolor="#f0fff0">
        <td><div align="right"><a href="add.html">返回留言</a> </td>
    </tr>
</table>
</html>

fichier del.php

<?php
include 'conn.php';
$id = $_GET['id'];
$query="delete from message where id=".$id;
mysql_query($query);
?>
<?php
//頁面跳轉(zhuǎn),實現(xiàn)方式為javascript
$url = "list.php";
echo "<script>";
echo "window.location.href='$url'";
echo "</script>";
?>

Allez sur ceci message board La rédaction est pratiquement terminée.Cet article ne sert que de point de départ. En tant qu'exemple le plus simple et le plus basique, les lecteurs peuvent d'abord comprendre comment utiliser PHP pour faire fonctionner la base de données et la combiner en un exemple simple.

Formation continue
||
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <link href="css.css" rel="stylesheet" type="text/css"> <title>Title</title> <?php include ("add.php")?> </head> <script> function CheckPost() { if(myform.user.value=="") { alert("請?zhí)顚懹脩?quot;); myform.user.focus(); return false; } if (myform.title.value.length<5) { alert("標(biāo)題不能少于5個字符"); myform.title.focus(); return false; } if (myform.content.value=="") { alert("內(nèi)容不能為空"); myform.content.focus(); return false; } } </script> <body> <b> <a href="list.php">瀏覽留言</a> </b> <hr size=1> <form action="add.php" method="post" name="myform" onsubmit="return CheckPost();"> 用戶:<input type="text" size="10" name="user"/><br> 標(biāo)題:<input type="text" name="title" /><br> 內(nèi)容:<textarea name="content"></textarea><br> <input type="submit" name="submit" value="發(fā)布留言" /> </form> </body> </html>
soumettreRéinitialiser le code