-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseller_request.php
More file actions
154 lines (137 loc) · 7.62 KB
/
Copy pathseller_request.php
File metadata and controls
154 lines (137 loc) · 7.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php
session_start();
// Ensure user is logged in
if (!isset($_SESSION['user_id'])) {
header("Location: authenticate.php");
exit();
}
$conn = mysqli_connect("localhost", "root", "", "clothingstore_db");
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$message = "";
$messageClass = "";
if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['submit_request'])) {
$brand = mysqli_real_escape_string($conn, $_POST['brand']);
$description = mysqli_real_escape_string($conn, $_POST['description']);
$product_name = mysqli_real_escape_string($conn, $_POST['product_name']);
$category = mysqli_real_escape_string($conn, $_POST['category']);
$user_id = $_SESSION['user_id'];
// Core native middleware configuration for file processing
$target_dir = "images/";
if (!file_exists($target_dir)) {
mkdir($target_dir, 0777, true);
}
$file_extension = strtolower(pathinfo($_FILES["clothing_image"]["name"], PATHINFO_EXTENSION));
$new_filename = "seller_" . $user_id . "_" . time() . "." . $file_extension;
$target_file = $target_dir . $new_filename;
$uploadOk = 1;
// Validate standard binary dimensions
$check = getimagesize($_FILES["clothing_image"]["tmp_name"]);
if($check === false) {
$message = "File validation failed: Visual asset is not an image.";
$messageClass = "alert-danger";
$uploadOk = 0;
}
// Limit structural configuration to 5MB allocations
if ($_FILES["clothing_image"]["size"] > 5000000) {
$message = "File layout boundary exception: File exceeds 5MB threshold size.";
$messageClass = "alert-danger";
$uploadOk = 0;
}
// Filter permitted layout file extensions
if($file_extension != "jpg" && $file_extension != "png" && $file_extension != "jpeg" && $file_extension != "webp") {
$message = "Format constraint: Supported file structures include JPG, JPEG, PNG, and WEBP.";
$messageClass = "alert-danger";
$uploadOk = 0;
}
if ($uploadOk == 1) {
if (move_uploaded_file($_FILES["clothing_image"]["tmp_name"], $target_file)) {
// Save metadata and file path logs into database table configuration
$query = "INSERT INTO products (product_name, category, brand, description, image_path, price, status, seller_id)
VALUES ('$product_name', '$category', '$brand', '$description', '$target_file', 0.00, 'pending', '$user_id')";
if (mysqli_query($conn, $query)) {
$message = "Asset dispatched successfully. Item pending validation log from administrative review channels.";
$messageClass = "alert-success";
} else {
$message = "Database write collision: " . mysqli_error($conn);
$messageClass = "alert-danger";
}
} else {
$message = "Server IO Error: Could not transfer asset to root repository logs.";
$messageClass = "alert-danger";
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Seller Request Portal | PASTIMES®</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
<style>
body { background-color: #000000; color: #ffffff; font-family: 'Inter', sans-serif; padding: 40px 0; }
.portal-card { background-color: #0c0c0c; border: 1px solid #222222; padding: 40px; border-radius: 0px; }
.form-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #888888; font-weight: 700; }
.form-control, .form-select { background-color: #000000; border: 1px solid #333333; color: #ffffff; border-radius: 0px; }
.form-control:focus, .form-select:focus { background-color: #000000; color:#fff; border-color: #0678eb; box-shadow: none; }
.btn-submit { background-color: #0678eb; color: white; border-radius: 0px; font-weight: 700; text-transform: uppercase; font-size: 12px; padding: 12px; border: none; width: 100%; transition: 0.3s; }
.btn-submit:hover { background-color: #0056b3; }
</style>
</head>
<body>
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<div class="mb-4">
<a href="index.php" class="text-decoration-none text-muted small fw-bold text-uppercase">
<i class="fa-solid fa-arrow-left me-2"></i> Return to Index
</a>
</div>
<div class="portal-card">
<h2 class="fw-bold text-uppercase mb-1" style="letter-spacing: 1px; font-size: 24px;">Seller Request Portal</h2>
<p class="text-muted mb-4 small">Submit item profile specifics below to schedule quality evaluation mapping from our administration unit.</p>
<?php if(!empty($message)): ?>
<div class="alert <?php echo $messageClass; ?> rounded-0 border-0 text-center small mb-4"><?php echo $message; ?></div>
<?php endif; ?>
<form action="seller_request.php" method="POST" enctype="multipart/form-data">
<div class="row">
<div class="col-md-6 mb-3">
<label class="form-label">Garment Piece Identifier</label>
<input type="text" name="product_name" class="form-control" placeholder="e.g., Oversized Graphic Tee" required>
</div>
<div class="col-md-6 mb-3">
<label class="form-label">Category Assignment</label>
<select name="category" class="form-select" required>
<option value="T-Shirts">T-Shirts</option>
<option value="Hoodies">Hoodies</option>
<option value="Bottoms">Bottoms</option>
<option value="Outerwear">Outerwear</option>
</select>
</div>
</div>
<div class="mb-3">
<label class="form-label">Clothing Brand / Manufacturer</label>
<input type="text" name="brand" class="form-control text-uppercase" placeholder="e.g., PASTIMES STUDIO, NIKE, VINTAGE" required>
</div>
<div class="mb-3">
<label class="form-label">Garment Condition & Quality Specification Description</label>
<textarea name="description" rows="4" class="form-control" placeholder="Identify size profiles, wear logs, material structures, and any defects contextually..." required></textarea>
</div>
<div class="mb-4">
<label class="form-label">Visual Asset File Upload</label>
<input type="file" name="clothing_image" class="form-control" accept="image/*" required>
</div>
<button type="submit" name="submit_request" class="btn btn-submit">
<i class="fa-solid fa-paper-plane me-2"></i> Dispatch Pipeline Request
</button>
</form>
</div>
</div>
</div>
</div>
</body>
</html>