getMessage(), (int)$e->getCode()); } $action = isset($_POST['action']) ? $_POST['action'] : ""; //set all values of the form to empty $activity=""; $description=""; $website=""; $image=""; if ($_SERVER["REQUEST_METHOD"] == "POST") { // form was submitted, place data into appropriate variables $activity = $_POST["activity"]; $description = $_POST["description"]; $website = $_POST["website"]; $image = $_POST["image"]; try { // set the PDO error mode to exception $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); //insert data into activity table $count = $pdo->exec("INSERT INTO activities_bop (activity,description,website,image) VALUES ('$activity', '$description','$website','$image')"); // echo the number of affected rows, if count =1 the record (row) was successfully inserted if($count == 1){ echo "record added to database"; } // close the database connection $pdo = null; } catch(PDOException $e) { echo $e->getMessage(); } } ?>