php account_add.php THEM thong tin PHP

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php account_add.php THEM thong tin PHP相关的知识,希望对你有一定的参考价值。

<?php
include ('database/connect.php');

$errors = [];
//cbi du lieu de INSERT
if (isset($_POST['submit'])) {
    if (!isset($_POST['name']) || $_POST['name'] == '') {
        $errors[] = 'Vui long nhap ten tai khoan';
    } else {
        $name = trim($_POST['name']);
    }
    if (!isset($_POST['status']) || $_POST['status'] == '') {
        $errors[] = 'Vui long chon trang thai';
    } else {
        $status = $_POST['status'];
    }

    if (!isset($_POST['type']) || $_POST['type'] == '') {
        $errors[] = 'Vui long chon loai tai khoan';
    } else {
        $type = $_POST['type'];
    }

    $note = isset($_POST['note']) ? $_POST['note'] : '';

    if (count($errors) == 0) {
        // INSERT INTO tenbang(column1, column2,...,columnn) VALUES(value1, value 2, ...,valuen);
        $sql = "INSERT INTO accounts (name, status, note, type, user_id) VALUES('$name', '$status', '$note', '$type', 1)";//test myPHP
        $query = $db_qltc->query($sql);
        if ($query) {
            header('Location: account_qltc.php');
            exit;
        }
    }
}

?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Thêm tài khoản mới</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
    <?php
    if (count($errors) > 0):
        for ($i = 0; $i < count($errors); $i++) :
    ?>
    <p style="color:red"><?php echo $errors[$i];?></p>
    <?php 
        endfor;
    endif;
    ?>
    <form action="" method="POST">
        <input type="text" name="name" value=""><br>
        <select name="status">
            <option value="">Chọn trạng thái</option>
            <option value="Open">Mở</option>
            <option value="Close">Đóng</option>
        </select><br>
        <select name="type">
            <option value="">Chọn loại tài khoản</option>
            <option value="TM">Tiền mặt</option>
            <option value="VDT">Ví điện tử</option>
            <option value="TKNH">Tài khoản ngân hàng</option>
        </select><br>
        <textarea name="note" cols="30" rows="10"></textarea>  
        <input type="hidden" name="user_id" value="1">
        <button type="submit" name="submit">Thêm mới</button>
    </form>
</body>
</html>

以上是关于php account_add.php THEM thong tin PHP的主要内容,如果未能解决你的问题,请参考以下文章

Git冲突:commit your changes or stash them before you can merge. 解决办法(转)

Git冲突:commit your changes or stash them before you can merge. 解决办法(转载)

ACM Find them, Catch them

ACM题目————Find them, Catch them

Find them, Catch them

POJ1703Find them, Catch them