The second-hand recycling website uses the product release and review function developed by PHP
With the rapid development of the second-hand commodity trading market, the second-hand recycling website has become the first choice platform for users to deal with idle items. However, in order to ensure the security and quality of transactions, the website needs to implement a product release review function. This article will introduce how to use PHP to develop the product release review function of a second-hand recycling website, and provide some code examples for reference.
<?php // 待审核商品列表页面 session_start(); // 启动会话 // 检查管理员是否已登录,若未登录则跳转到登录页面 if (!isset($_SESSION['admin'])) { header("Location: login.php"); exit(); } // 查询待审核的商品列表 $query = "SELECT * FROM products WHERE status = 'pending'"; $result = mysqli_query($conn, $query); ?> <!DOCTYPE html> <html> <head> <title>商品审核</title> </head> <body> <h1>待审核商品列表</h1> <table> <tr> <th>商品ID</th> <th>标题</th> <th>价格</th> <th>操作</th> </tr> <?php while ($row = mysqli_fetch_assoc($result)): ?> <tr> <td><?php echo $row['id']; ?></td> <td><?php echo $row['title']; ?></td> <td><?php echo $row['price']; ?></td> <td><a href="review.php?id=<?php echo $row['id']; ?>">审核</a></td> </tr> <?php endwhile; ?> </table> </body> </html>
When the administrator clicks the "review" link of a product, it will jump to the review page. The following is a sample code for the audit page:
<?php // 审核具体商品页面 session_start(); // 启动会话 // 检查管理员是否已登录,若未登录则跳转到登录页面 if (!isset($_SESSION['admin'])) { header("Location: login.php"); exit(); } // 获取商品ID $id = $_GET['id']; // 查询商品信息 $query = "SELECT * FROM products WHERE id = $id"; $result = mysqli_query($conn, $query); $row = mysqli_fetch_assoc($result); // 提交审核结果 if ($_SERVER['REQUEST_METHOD'] === 'POST') { $status = $_POST['status']; $feedback = $_POST['feedback']; // 更新商品审核信息 $updateQuery = "UPDATE product_review SET status = '$status', feedback = '$feedback' WHERE product_id = $id"; mysqli_query($conn, $updateQuery); } ?> <!DOCTYPE html> <html> <head> <title>商品审核</title> </head> <body> <h1>审核商品</h1> <h2><?php echo $row['title']; ?></h2> <p><?php echo $row['description']; ?></p> <form method="POST"> <input type="radio" name="status" value="approved"> 通过 <input type="radio" name="status" value="rejected"> 拒绝 <br> <textarea name="feedback" placeholder="审核意见"></textarea> <br> <input type="submit" value="提交"> </form> </body> </html>
// 提交审核结果 if ($_SERVER['REQUEST_METHOD'] === 'POST') { $status = $_POST['status']; $feedback = $_POST['feedback']; // 更新商品审核信息 $updateQuery = "UPDATE product_review SET status = '$status', feedback = '$feedback' WHERE product_id = $id"; mysqli_query($conn, $updateQuery); }
The above example is just a simple demonstration, and the actual business logic and page design may be more complex. But through this example, we can understand how to use PHP to develop the product release review function of a second-hand recycling website. Hope this article helps you!
The above is the detailed content of The second-hand recycling website uses the product release and review function developed in PHP. For more information, please follow other related articles on the PHP Chinese website!