if (!empty($errors)) { // if there are items in our errors array, return those errors $data['success'] = false; $data['errors'] = $errors; } else { // if there are no errors process our form, then return a message // DO ALL YOUR FORM PROCESSING HERE moveChangeCommentString($compDir, $fileMoveName, $newDir); moveScssFile($compDir, $fileMoveName, $newDir); deleteScssImportString($compDir, $fileMoveName); writeScssImportFile($newDir, $fileMoveName); moveCompFile($compDir, $fileMoveName, $newDir); deleteCompIncludetString($compDir, $fileMoveName); createIncludeString($newDir, $fileMoveName); deleteAjaxCompFile($compDir, $fileMoveName); createAjaxIncludeAndCompFile($newDir, $fileMoveName); // show a message of success and provide a true success variable $data['success'] = true; $data['message'] = 'Success!'; } // return all our data to an AJAX call echo json_encode($data); ?> <?php
} elseif ($_POST['renameFileName'] == "") { $errors['name'] = 'Name is required.'; } // return a response =========================================================== // if there are any errors in our errors array, return a success boolean of false if (!empty($errors)) { // if there are items in our errors array, return those errors $data['success'] = false; $data['errors'] = $errors; } else { // if there are no errors process our form, then return a message // DO ALL YOUR FORM PROCESSING HERE changeCommentString($catName, $renameFileName, $oldName); changeScssCommentString($catName, $renameFileName, $oldName); renameScssFile($catName, $renameFileName, $oldName); deleteScssImportString($catName, $oldName); writeScssImportFile($catName, $renameFileName); renameCompFile($catName, $renameFileName, $oldName); deleteCompIncludetString($catName, $compNotes, $oldName, $bgColor); createIncludeString($catName, $compNotes, $renameFileName, $bgColor); deleteAjaxCompFile($catName, $oldName); createAjaxIncludeAndCompFile($catName, $renameFileName); // show a message of success and provide a true success variable $data['success'] = true; $data['message'] = 'Success!'; } // return all our data to an AJAX call echo json_encode($data); ?>
$bgColor = test_input($_POST["bgColor"]); $fileExists = '../../components/' . $compDir . '/' . $fileCreateName . '.' . $compExt . ''; if (file_exists($fileExists) && $fileCreateName != "") { $errors['exists'] = 'A file named ' . $fileCreateName . ' already exists.'; } elseif ($_POST['fileCreateName'] == "") { $errors['name'] = 'Name is required.'; } // return a response =========================================================== // if there are any errors in our errors array, return a success boolean of false if (!empty($errors)) { // if there are items in our errors array, return those errors $data['success'] = false; $data['errors'] = $errors; } else { // if there are no errors process our form, then return a message // DO ALL YOUR FORM PROCESSING HERE createScssFile($compDir, $fileCreateName); writeScssImportFile($compDir, $fileCreateName); createCompFile($compDir, $fileCreateName); createIncludeString($compDir, $compNotes, $fileCreateName, $bgColor); createAjaxIncludeAndCompFile($compDir, $fileCreateName); // show a message of success and provide a true success variable $data['success'] = true; $data['message'] = 'Success!'; } // return all our data to an AJAX call echo json_encode($data); ?>