@eSCphr

Не добавляется тарифный план в бд,в чём проблема?

Где ошибка в коде,не могу понять
Пишет что добавилось но в бд ничего нету..
<?php
					if (isset($_POST['addPackage']))
					{
						$name = $_POST['name'];
						$price = $_POST['price'];
						$length = $_POST['length'];
						$unit = $_POST['unit'];
						$maxboot = $_POST['maxboot'];
						$concurrents = $_POST['concurrents'];
						$methods = $_POST['methods'];
						$public = $_POST['public'];
						$errors = array();
						
							if (empty($name) || empty($price) || empty($length) || empty($unit) || empty($maxboot) || empty($concurrents) || empty($methods) || empty($public))
							{
								$errors[] = 'Please fill in all fields.';
							}
							
							if(empty($errors)) {
								$insertPackage = $odb -> prepare("INSERT INTO `packages` VALUES (NULL, :name, :price, :maxboot, :unit, :length, :concurrents, :methods, :public, :hoston)");
								$insertPackage -> execute(array(':name' => $name, ':price' => $price, ':maxboot' => $maxboot, ':unit' => $unit, ':length' => $length, ':concurrents' => $concurrents, ':methods' => json_encode($methods), ':public' => $public, ':hoston' => $hoston));
								echo '<div class="alert alert-success"><a class="close" data-dismiss="alert" href="#" aria-hidden="true">×</a><strong>Success!</strong><br> You have added a new package successfully!</div>';
							} else {
								echo '<div class="alert alert-danger"><a class="close" data-dismiss="alert" href="#" aria-hidden="true">×</a><strong>Error!</strong><br />';
								foreach($errors as $error)
								{
									echo '- '.$error.'<br />';
								}
								echo '</div>';
							}
					}
				?>
  • Вопрос задан
  • 55 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы