handler.php 774 B

1234567891011121314151617181920212223
  1. <?php
  2. ini_set('error_reporting', E_ALL);
  3. ini_set('display_errors', 1);
  4. ini_set('display_startup_errors', 1);
  5. require_once('lib/CallbackForm.php');
  6. include_once('lib/FormWithEmail.php');
  7. require_once('lib/FormFactory.php');
  8. $name = isset($_POST['name']) ? trim($_POST['name']) : '';
  9. $phone = isset($_POST['phone']) ? trim($_POST['phone']) : '';
  10. $email = isset($_POST['email']) ? trim($_POST['phone']) : ' ';
  11. $uploadFile = isset($_FILES['uploadFile']) ? ($_FILES['uploadFile']) : [];
  12. $formType = isset($_POST['formType']) ? trim($_POST['formType']) : '';
  13. $form = FormFactory::getForm($formType, $name, $phone, $email, $uploadFile);
  14. if ($form->validate()) {
  15. $form->send();
  16. $form->uploadFile();
  17. } else {
  18. echo 'Введите корректные данные';
  19. }