コード例 #1
0
ファイル: product.php プロジェクト: ndm93bn/webbanhang
if (isset($_SESSION['user_id'])) {
    $user = getUserById($_SESSION['user_id']);
} else {
    redirect("index.php?controller=user&action=login");
}
if (isset($_GET['action'])) {
    $action = $_GET['action'];
    switch ($action) {
        case "new":
            newProduct();
            break;
        case "edit":
            editProduct($_GET['id']);
            break;
        case "view":
            viewProduct($_GET['id']);
            break;
        case "delete":
            deleteProduct($_GET['id']);
            break;
        default:
            echo "URL not found";
    }
} else {
    include "view/product/index.php";
}
function viewProduct($id)
{
    $product = getProductById($id);
    include "view/product/view.php";
}
コード例 #2
0
     $id = strip_tags($_POST['id']);
     $quantity = strip_tags($_POST['quantity']);
     $genre = strip_tags($_POST['genre']);
     $platform = strip_tags($_POST['platform']);
     $name = strip_tags($_POST['name']);
     $image = strip_tags($_POST['image']);
     $description = strip_tags($_POST['description']);
     $price = strip_tags($_POST['price']);
     if (isset($_POST['$taxable'])) {
         $taxable = 1;
     } else {
         $taxable = 0;
     }
     if (!empty($id) && !empty($quantity) && !empty($genre) && !empty($platform) && !empty($name) && !empty($image) && !empty($description) && !empty($price)) {
         require_once 'maintain_products.php';
         $result = viewProduct($id);
         $rows = mysql_num_rows($result);
         if ($rows > 0) {
             // This product exists, therefore you need to update.
             updateProduct($id, $quantity, $genre, $platform, $name, $image, $description, $price, $taxable);
         } else {
             // This is a new product.
             addProduct($quantity, $genre, $platform, $name, $image, $description, $price, $taxable);
         }
     } else {
         echo 'Please go back and make sure to fill out all the fields.';
     }
     echo '<br /><br /><a href="addUpdateProducts.php">Go back</a>';
 } else {
     echo "You do not have the permissions to do that.";
 }