diff --git a/form.php b/form.php index 5277f01..c08c2b0 100644 --- a/form.php +++ b/form.php @@ -3,5 +3,9 @@ if (isset($_POST) && !empty($_POST)) { $SubmitForm = new SubmitForm(); - $SubmitForm->call($_POST); + if ($SubmitForm->call($_POST)) { + echo true; + } else { + echo false; + } } diff --git a/index.php b/index.php index 7721384..91ee42e 100644 --- a/index.php +++ b/index.php @@ -37,6 +37,8 @@

Secret Santa

Add each person's name and email who is participating in the Secret Santa drawing. Select the suggested price and hit the send email button. Everyone will receive an email with who they have been randomly select to purchase a gift for.

+
+
diff --git a/js/jquery.scripts.js b/js/jquery.scripts.js index 93e177d..9908b7f 100644 --- a/js/jquery.scripts.js +++ b/js/jquery.scripts.js @@ -24,8 +24,37 @@ function newFormElementsString(numberOfPeople) { return formString; } +function formFeedback(status) { + if (status == 1) { + $('.feedback').html(""); + } else { + $('.feedback').html(""); + } + +} + +function formStarted() { + $('.feedback').html(""); +} + +function submitForm(form) { + formStarted(); + $.post( + form.attr('action'), + form.serialize(), + function(data, textStatus) { + formFeedback(data); + } + ); +} + jQuery(document).ready(function(){ $('button._add_person').on('click', function() { addAnotherPerson(); }); + + $('form').on('submit', function(event){ + submitForm($(this)); + event.preventDefault(); + }); });