/
home
/
u839856410
/
domains
/
frajuuconnect.online
/
public_html
/
Upload File
HOME
<?php session_start(); if(!isset($_SESSION['agent_id'])) { header("Location: login.php"); exit(); } $conn = new mysqli("localhost", "u369989615_Frajuu", "Frajuuconnect25@", "u369989615_frajuu_connect"); if($conn->connect_error){ die("Connection failed: ".$conn->connect_error); } $agent_id = $_SESSION['agent_id']; if($_SERVER['REQUEST_METHOD']=='POST'){ $name = $conn->real_escape_string($_POST['name']); $region = $conn->real_escape_string($_POST['region']); $district = $conn->real_escape_string($_POST['district']); $location = $conn->real_escape_string($_POST['location']); $rent = $_POST['rent']; $bedrooms = $_POST['bedrooms'] ?? 0; $bathrooms = $_POST['bathrooms'] ?? 0; $description = $conn->real_escape_string($_POST['description']); $status = $_POST['status']; // Handle Images $image_paths = []; if(!empty($_FILES['images']['name'][0])){ foreach($_FILES['images']['tmp_name'] as $key => $tmp_name){ $filename = time().'_'.basename($_FILES['images']['name'][$key]); move_uploaded_file($tmp_name, "uploads/".$filename); $image_paths[] = "uploads/".$filename; } } $images_json = json_encode($image_paths); // Handle Videos (optional) $video_paths = []; if(!empty($_FILES['videos']['name'][0])){ foreach($_FILES['videos']['tmp_name'] as $key => $tmp_name){ $filename = time().'_'.basename($_FILES['videos']['name'][$key]); move_uploaded_file($tmp_name, "uploads/".$filename); $video_paths[] = "uploads/".$filename; } } $videos_json = json_encode($video_paths); // Insert into rooms_for_rent table $sql = "INSERT INTO rooms_for_rent (agent_id, name, region, district, location, rent, description, images, videos, status) VALUES ('$agent_id','$name','$region','$district','$location','$rent','$description','$images_json','$videos_json','$status')"; if($conn->query($sql)){ header("Location: add-room.php?msg=success"); exit(); } else { die("Error: ".$conn->error); } } ?>