Пример #1
0
if (!empty($_POST)) {
    $p_name = $_POST['p_name'];
    $p_description = $_POST['p_description'];
    $p_class = $_POST['p_class'];
    $p_price = $_POST['p_price'];
    $p_state = 2;
    if ($p_name == null || $p_name == '') {
        $a['msg'] = "产品名称不能为空";
    } else {
        if ($p_price == null || $p_price == '') {
            $a['msg'] = "产品价格不能为空";
        } else {
            if (!preg_match("/^\\d{0,8}\\.{0,1}(\\d{1,2})?\$/", $p_price)) {
                $a['msg'] = "产品价格无效";
            } else {
                $p = new \Ss\Product\Product();
                $p->Create($p_name, $p_description, $p_class, $p_price, $p_state);
                $a['ok'] = '1';
                $a['msg'] = "添加成功";
            }
        }
    }
    echo json_encode($a);
    if ('1' == $a['ok']) {
        echo ' <script>alert("添加成功!")</script> ';
        echo " <script>window.location='product.php';</script> ";
    } else {
        echo " <script>alert('{$a['msg']}')</script> ";
    }
}
?>
Пример #2
0
        </section><!-- /.content -->

        <?php 
if ($show_product) {
    ?>

        <!-- Content Header (Page header) -->
        <section class="content-header">
            <h1>
                套餐购买
                <small>Package Purchase</small>
            </h1>
        </section>

        <?php 
    $product = new \Ss\Product\Product();
    $products = $product->AllProduct();
    ?>

        <!-- Main content -->
        <section class="content">
            <div class="row">
            <?php 
    foreach ($products as $p) {
        ?>
                <!-- left column -->
                <div class="col-md-3">
                    <!-- general form elements -->
                    <div class="box box-primary">
                        <div class="box-body">
                            <form action="pay.php" method="post">