0
if($_REQUEST['subview']=="add")

   {

          $title = mysqli_real_escape_string($db->conn,$_POST['title']);

          $cat_id = mysqli_real_escape_string($db->conn,$_POST['category']);

          $area = mysqli_real_escape_string($db->conn,$_POST['area']);

          $bedroom = mysqli_real_escape_string($db->conn,$_POST['bedroom']);

          $bathroom = mysqli_real_escape_string($db->conn,$_POST['bathroom']);

          $garage = mysqli_real_escape_string($db->conn,$_POST['garage']);

          $content=mysqli_real_escape_string($db->conn,$_POST['text']);

          $data = array("title"=>$title,

                         "cat_id"=>$cat_id,

                         "area"=>$area,

                         "bedroom"=>$bedroom,

                         "bathroom"=>$bathroom,

                         "garage"=>$garage,

                         "content"=>$content,

                        "status"=>"active",

                        "added_date"=>date("Y-m-d H:i:s", time())

             );

          if($db->insert($data,'bk_property') == true)  

            {

            $last_id = mysqli_insert_id($db->conn);

            if($_FILES['image']['name']!="")

                 {

                    $check = getimagesize($_FILES["image"]["tmp_name"]);

    if($check !== false) {

                   $image = $_FILES['image']['name'];

                   $exp = explode(".",$image);

                   $extension = end($exp);

                   $image_name = "property_".$date.".".$extension;

                    $upload = move_uploaded_file($_FILES['image']['tmp_name'],"../aboutus/".$image_name);

                    if($upload)

                      {

                        $thumbnail = $obj->generateThumbnail("../aboutus/".$image_name, "../aboutus/thumb/".$image_name, 370, 250);

                        $sql2 = "UPDATE bk_property SET image_name='".$image_name."' WHERE id='".$last_id."'";

                        $update_image = mysqli_query($db->conn,$sql2) or die(mysqli_connect_errno()."Data cannot inserted");

                      }

                      }

  else {

        $_SESSION['property'] = "File is Not an image!";

            echo "<script>window.location.href='../properties.php?subview=list'</script>"; 

       }  

                 }

            $_SESSION['property'] ="Added Success Fully.";

            echo "<script>window.location.href='../properties.php?subview=list'</script>";    

            }

          else

            {

            $_SESSION['property'] ="Image couldn't be added.Please try again.";

            echo "<script>window.location.href='../properties.php?subview=add'</script>";   

            }   

   }

``

3
Contributors
2
Replies
13
Views
2 Weeks
Discussion Span
Last Post by Dani
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.