PDO::ERRMODE_EXCEPTION )); }catch (Exception $e) { die("Error : ".$e->getMessage()); } // /* Create Table if not exists */ // $sql = file_get_contents($root."/database/create_record.sql"); // $db->exec($sql); $req = $db->prepare('SELECT id FROM `authors` WHERE username=:username'); $req->execute(array( "username"=>$_SESSION['username'] )); if ($data = $req->fetch()) { $id = $data['id']; } try { $req = $db->prepare('INSERT INTO `records` (author_id, recordist_name, file_name, license, species, subspecies, sound_type, country, lat, lng, date, time, remarks) VALUES ( :id, :recordist_name, :file_name, :license, :species, :subspecies, :sound_type, :country, :lat, :lng, :date, :time, :remarks)'); $req->execute(array( "id"=>$id, "recordist_name"=>$_SESSION['observation']['recordist-name'], "file_name"=>$_SESSION['observation']['file'], "license"=>$_SESSION['observation']['license'], "species" => $_SESSION['observation']['species'], "subspecies"=>$_SESSION['observation']['subspecies'], "sound_type"=>implode(',', $_SESSION['observation']['type']), "country"=>$_SESSION['observation']['country'], "lat"=>$_SESSION['observation']['lat'], "lng"=>$_SESSION['observation']['lng'], "date"=>$_SESSION['observation']['date'], "time"=>$_SESSION['observation']['time'], "remarks"=>$_SESSION['observation']['remarks'], )); } catch (Exception $e) { die("Error : ".$e->getMessage()); } header('Location: '."/"); ?>