// Clean up the form submissions $cleanCode = filter_var($code, FILTER_SANITIZE_STRING); $cleanEmail = filter_var($email, FILTER_SANITIZE_EMAIL); $cleanAlbum = filter_var($album, FILTER_SANITIZE_STRING); // validate the email format $validEmail = filter_var($cleanEmail, FILTER_VALIDATE_EMAIL); // Validate the code entered $validCode = $dl->validate_code($album, $code); // Check if the code and email entered are valid if ($validEmail && $validCode === 200) { // Subscribe the user if they kept the subscribe option checked if ($subscribe) { $addUser = $mail->newsletterSignup($cleanEmail); print_r($addUser); } $albumInfo = $dl->get_album_info($cleanAlbum); // Send the verification email via Mandrill $verificationEmail = $mail->sendMail($cleanCode, $cleanEmail, $albumInfo['artist'], $album, $albumInfo['title'], $albumInfo['thumbnail']); // Make sure the email was received and properly sent if ($verificationEmail[0]['status'] === 'sent' || $verificationEmail[0]['status'] === 'queued') { // Redirect to the redeem download page $app->redirect('./redeem/' . $cleanAlbum . '/' . $cleanCode); } else { $app->flash('email', 'Your verfication email did not send. You can bookmark this page to return to your download.'); $app->redirect('./redeem/' . $cleanAlbum . '/' . $cleanCode); } } else { if (!$validEmail) { $app->flash('error', 'The email address you entered is not a valid format.'); } if ($validCode == 404) {