setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $planete = $_POST['planete']; $nom = $_POST['nom']; $date = $_POST['date']; $url = $_POST['url']; $description = $_POST['description']; $allowedTables = [ 'mercury' => 'MERCURY', 'venus' => 'VENUS', 'earth' => 'EARTH', 'mars' => 'MARS', 'jupiter' => 'JUPITER', 'saturn' => 'SATURN', 'uranus' => 'URANUS', 'neptune' => 'NEPTUNE' ]; if (array_key_exists($planete, $allowedTables)) { $nomTable = $allowedTables[$planete]; $stmt = $pdo->prepare("INSERT INTO $nomTable (title, date, url, explanation) VALUES (?, ?, ?, ?)"); $stmt->execute([$nom, $date, $url, $description]); $message = "

Row successfully added to the $nomTable table!

"; } } catch (PDOException $e) { $message = "

SQL Error: " . $e->getMessage() . "

"; } } ?> Admin Panel - OpenPlanetsMaps

Admin Login

Add a row