*/ require_once "../model/ContributionController.php"; require_once "../model/objects/Contribution.php"; if ($_SERVER['REQUEST_METHOD'] == "post" || $_SERVER['REQUEST_METHOD'] == "POST") { if (array_key_exists('name', $_REQUEST) && array_key_exists('email', $_REQUEST) && array_key_exists('pn', $_REQUEST) && array_key_exists('pa', $_REQUEST) && array_key_exists('pc', $_REQUEST) && array_key_exists('pm', $_REQUEST) && array_key_exists('pr', $_REQUEST)) { //only if all data is available $name = decodeInput($_REQUEST['name']); $email = decodeInput($_REQUEST['email']); $poiName = decodeInput($_REQUEST['pn']); $poiAddress = decodeInput($_REQUEST['pa']); $poiMessage = decodeInput($_REQUEST['pm']); $poiCategory = decodeInput($_REQUEST['pc']); $poiRequest = decodeInput($_REQUEST['pr']); $contributionController = new ContributionController(); $contribution = new Contribution(); $contribution->init($name, $email, $poiName, $poiAddress, $poiCategory, $poiMessage, $poiRequest); if ($contributionController->add($contribution)) { sendThankyouMail($contribution); echo "success"; exit; } else { echo "error cannot add"; exit; } } else { echo "error post keys missing"; exit; } } else { echo "error not a post request"; exit;