ممكن تعدلون على الكود بتاعي الى اضافة خانة لرفع IP الشخص الذي يرفع المنشور :
if(isset($_POST['add_product'])){
$name = $_POST['name'];
$name = filter_var($name, FILTER_SANITIZE_STRING);
$price = $_POST['price'];
$price = filter_var($price, FILTER_SANITIZE_STRING);
$city = $_POST['city'];
$city = filter_var($city, FILTER_SANITIZE_STRING);
$date = $_POST['date'];
$date = filter_var($date, FILTER_SANITIZE_STRING);
$number = $_POST['number'];
$number = filter_var($number, FILTER_SANITIZE_STRING);
$place = $_POST['place'];
$place = filter_var($place, FILTER_SANITIZE_STRING);
$category = $_POST['category'];
$category = filter_var($category, FILTER_SANITIZE_STRING);
$details = $_POST['details'];
$details = filter_var($details, FILTER_SANITIZE_STRING);
$open = $_POST['open'];
$open = filter_var($open, FILTER_SANITIZE_STRING);
$image = $_FILES['image']['name'];
$image = filter_var($image, FILTER_SANITIZE_STRING);
$image_size = $_FILES['image']['size'];
$image_tmp_name = $_FILES['image']['tmp_name'];
$image_folder = 'uploaded_img/'.$image;
$image_type=$_FILES['image']['type'];
$select_products = $conn->prepare("SELECT * FROM `acses` WHERE name = ?");
$select_products->execute([$name]);
if(! in_array($image_type,array('image/png','image/gif','image/jpg','image/jpeg'))){
$errors[] = $message['center'] = 'قم بتحميل صورة صالحة بالضغط على المربع الاصفر';
}else{
$insert_products = $conn->prepare("INSERT INTO `acses`(name, category, details, price, image, number, place,type,city,date) VALUES(?,?,?,?,?,?,?,?,?,?)");
$insert_products->execute([$name, $category, $details, $price, $image, $number, $place,$image_type,$city,$date ]);
if($insert_products){
if($image_size > 2000000){
$message[] = 'حجم الصورة جدا كبير';
}else{
move_uploaded_file($image_tmp_name, $image_folder);
$message[] = 'تم نشر الإعلان';
}
}
}
};
التعليقات