public function registerUser($username, $first_name, $last_name, $email, $email_check, $role_id, $description, $password, $password_check) { $connection = ConnectionManager::getConnection(); $success = false; Logger::log('sendInput'); $passwordConfirm = $this->isEqual($password, $password_check); $emailConfirm = $this->isEqual($email, $email_check); if (isset($_POST['submit'])) { $sql = "SELECT id FROM user WHERE username = '******'"; $result = $connection->query($sql); if ($result->num_rows < 1) { if ($passwordConfirm && $emailConfirm) { $username = $connection->escape_string($username); $first_name = $connection->escape_string($first_name); $last_name = $connection->escape_string($last_name); $email = $connection->escape_string($email); $role_id = $connection->escape_string($role_id); $description = $connection->escape_string($description); $password = $connection->escape_string($password); $sql = "INSERT INTO user(first_name, last_name, email, role_id, username, password, description, notifications) VALUES('{$first_name}','{$last_name}','{$email}','{$role_id}', '{$username}','{$password}', '{$description}', 1)"; if ($connection->query($sql) === TRUE) { $this->confirmAccountEmail($email); $success = true; Logger::log('connected to database'); } else { Logger::log('not connected to database'); } } } else { if ($result->num_rows >= 1) { Alerter::showAlert("username already used"); } } } return $success; }
$fileName = $_FILES['userfile']['name']; //image name $tmpName = $_FILES['userfile']['tmp_name']; // data $fileSize = $_FILES['userfile']['size']; $fileType = $_FILES['userfile']['type']; $categories = $_POST['category']; $auctionManager = new AuctionManager(); $imageManager = new ImageManager(); $imageAuctionID = -1; if ($tmpName != null) { $imageID = $imageManager->uploadImage($tmpName, $fileType); \Models\Logger::log($imageID); if ($imageID > 0) { $auctionID = $auctionManager->createNewItem($title, $description, $item_condition, $start_price, $reserve_price, $start_date, $start_time, $end_date, $end_time, $categories); if ($auctionID > 0) { $imageAuctionID = $auctionManager->registerImage($auctionID, $imageID); \Models\Logger::log($imageAuctionID); } } } if ($imageAuctionID > 0) { $auctionDetail = $auctionManager->getAuctionDetail($auctionID); $uploadSuccessView = new UploadSuccessView($auctionDetail); $uploadSuccessView->render(); } else { $uploadView = new UploadView(); \Models\Alerter::showAlert("There was a problem with your upload"); $uploadView->render(); } }