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

PHP development corporate website tutorial: Add news information

Click the add button to jump to the addne.php page

Let’s take a look at the addne.php code:

<!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="addnews.php">
        標題:<input type="text" name="title" class="ipt">
        </br></br>
        內容:<textarea cols="50" rows="5" name="content" class="txt"></textarea></br></br>
        <select name="type">
            <option value="0">公司公告</option>
            <option value="1">公司新聞</option>
        </select>
        </br></br>
        <input type="submit" value="添加" class="sub">
    </form>
</body>
</html>

Look at the above code: form submission addnews.php page

Let’s look at the code of the following addnews.php page:

<?php
    //添加新聞資訊
    require_once('conn.php');
    $title=$_POST['title'];
    $content = $_POST['content'];
    $type = $_POST['type'];
    $newtime = time();

    $sql  = "insert into `news`(title,type,content,newtime) values('$title','$type','$content','$newtime')";
    $res = mysql_query($sql);
    if($res){
        echo "<script>alert('添加新聞成功');location.href='news.php';</script>";
    }else{
        echo "<script>alert('添加新聞失敗');location.href='news.php';</script>";
    }

?>

Get the form information, then add it to the database table, and then judge whether the addition is successful

Continuing Learning
||
<!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="addnews.php"> 標題:<input type="text" name="title" class="ipt"> </br></br> 內容:<textarea cols="50" rows="5" name="content" class="txt"></textarea></br></br> <select name="type"> <option value="0">公司公告</option> <option value="1">公司新聞</option> </select> </br></br> <input type="submit" value="添加" class="sub"> </form> </body> </html>
submitReset Code