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; } function sendThankyouMail(Contribution $contribution)
if ($_SERVER['REQUEST_METHOD'] == "post" || $_SERVER['REQUEST_METHOD'] == "POST") { if (array_key_exists("name", $_POST) && array_key_exists("email", $_POST) && array_key_exists("title", $_POST) && array_key_exists("message", $_POST) && array_key_exists("rate", $_POST) && array_key_exists("du", $_POST) && array_key_exists("dn", $_POST) && array_key_exists("dv", $_POST)) { //only if all data is available $name = decodeInput($_REQUEST['name']); $email = decodeInput($_REQUEST['email']); $subject = decodeInput($_REQUEST['title']); $message = decodeInput($_REQUEST['message']); $rating = decodeInput($_REQUEST['rate']); $deviceUser = decodeInput($_REQUEST['du']); $deviceName = decodeInput($_REQUEST['dn']); $deviceVersion = decodeInput($_REQUEST['dv']); $feedbackController = new FeedbackController(); $feedback = new Feedback(); $feedback->init($name, $email, $subject, $message, $rating, $deviceUser, $deviceName, $deviceVersion); if ($feedbackController->add($feedback)) { sendThankyouMail($name, $email, $subject); echo "success"; exit; } else { echo "error"; exit; } } else { echo "error"; exit; } } else { echo "error"; exit; } function sendThankyouMail($name, $email, $title)