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

PHP開發(fā)企業(yè)網(wǎng)站教程之添加關(guān)于我們信息

看下面的代碼:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>添加信息</title>
    <style type="text/css">
        .ipt{width:180px;height:30px;border-radius:5px;
            outline:none;border:1px solid #eee;box-sizing:border-box;padding-left:15px;}
        .txt{width:250px;height:200px;}
        .sub{width:50px;height:20px;border:1px solid #eee;background:#eee;color:#ff7575;}
    </style>
</head>
<body>
    <form method="post" action="addabout.php">
        標題:<input type="text" name="title" class="ipt">
        </br></br>
        內(nèi)容:<textarea cols="50" rows="5" name="content" class="txt"></textarea></br></br>
        <input type="submit" value="添加" class="sub">
    </form>
</body>
</html>

表單提交到 addabout.php 頁面 進行處理

代碼如下:

<?php
    require_once('conn.php');
    //htmlspecialchars()  過濾html
    $title = htmlspecialchars($_POST['title']);
    $content = htmlspecialchars($_POST['content']);
    if(empty($title)){
        echo "請輸入標題";
    }else if(empty($content)){
        echo "請輸入內(nèi)容";
    }else{
        $sql  = "insert into `about`(title,content) values('$title','$content')";
        $res = mysql_query($sql);
        if($res){
            echo "<script>alert('添加信息成功');location.href='about.php';</script>";
        }else{
            echo "<script>alert('添加信息失敗');history.go(-1);</script>";
        }
    }    
?>

獲取表單的信息,然后添加到數(shù)據(jù)庫

繼續(xù)學習
||
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>添加信息</title> <style type="text/css"> .ipt{width:180px;height:30px;border-radius:5px; outline:none;border:1px solid #eee;box-sizing:border-box;padding-left:15px;} .txt{width:250px;height:200px;} .sub{width:50px;height:20px;border:1px solid #eee;background:#eee;color:#ff7575;} </style> </head> <body> <form method="post" action="addabout.php"> 標題:<input type="text" name="title" class="ipt"> </br></br> 內(nèi)容:<textarea cols="50" rows="5" name="content" class="txt"></textarea></br></br> <input type="submit" value="添加" class="sub"> </form> </body> </html>
提交重置代碼