redirect_to("login.php"); } if ($session->user_id != $room->hotel_id) { redirect_to("login.php"); } $count_photo = RoomPhoto::find_photo_by_room($room->id); $max_file_size = 1048567; $message1 = ""; $message2 = ""; $message3 = ""; $message4 = ""; if (isset($_POST['submit'])) { if (empty($count_photo)) { $room_photo = new RoomPhoto(); $room_photo->room_id = $room->id; $room_photo->attach_file($_FILES['upload_file']); if ($room_photo->save()) { redirect_to("hotel_page.php?id={$room->hotel_id}"); } else { $message1 = join("<br>", $room_photo->errors); } } else { $count_photo->attach_file($_FILES['upload_file']); if ($count_photo->update()) { redirect_to("hotel_page.php?id={$room->hotel_id}"); } else { $message1 = join("<br>", $count_photo->errors); } } } ?>