Exemplo n.º 1
0
                 $img = imagecreatefrompng($filepath);
             }
             $width = imagesx($img);
             $height = imagesy($img);
             $new_width = 200;
             $new_height = floor($height * ($new_width / $width));
             $tmp_img = imagecreatetruecolor($new_width, $new_height);
             imagecopyresized($tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
             imagejpeg($tmp_img, __DIR__ . "/../thumbnails/" . basename($image));
         }
     }
 }
 try {
     // Connect to the database
     $conn = new DBCommunication();
     $conn->beginTransaction();
     // Get user, who is logged in and posting ad, id
     $query = "SELECT user_id FROM whwp_User WHERE user_username = :username";
     $conn->prepQuery($query);
     $conn->bind('username', $username);
     $resultset = $conn->single();
     $user_id = $resultset->user_id;
     // Insert some data to the database.
     $query = "INSERT INTO whwp_Advert (advert_owner, advert_price, advert_bookname, advert_date, advert_description, advert_category) " . "VALUES (:user_id, :price, :title, :date, :description, :category)";
     $conn->prepQuery($query);
     $conn->bindArrayValue(array('user_id' => $user_id, 'price' => $price, 'title' => $title, 'date' => gmdate('Y-m-d'), 'description' => $description, 'category' => $category_id));
     $conn->execute();
     // Get the auto generated advert_id.
     $advert_id = $conn->lastInsertId();
     if (isset($_POST['condition'])) {
         $query = "UPDATE whwp_Advert SET advert_condition=:condition WHERE advert_id = :advert_id";