<?php
session_start();
require_once "front_common/header.php";

$db = new DbHandler();
?>

<div class="body-overlay"></div>
<section class="section-padding">
    <div class="well-lg">
        <div class="container no-padding">
            <div class="col-sm-10 offset-sm-1 col-xs-12">
                <?php
                if (isset($_GET['email']) && isset($_GET['code'])) {
                    $email = $_GET['email'];
                    $code = $_GET['code'];

                    if ($db->subscriptionExist($email, $code)) {
                        $response = $db->unSubscribeUser($email);
                        if ($response["error"] == false) { ?>
                            <div id="error" class="box-message box-message-success">
                                <div class="box-message-content">
                                    <p id="message"><?php echo $response["message"] ?></p>
                                </div>
                            </div>
                        <?php } else { ?>
                            <div id="error" class="box-message box-message-error">
                                <div class="box-message-content">
                                    <p id="message"><?php echo $response["message"] ?></p>
                                </div>
                            </div>
                        <?php }
                    } else { ?>
                        <div id="error" class="box-message box-message-error">
                            <div class="box-message-content">
                                <p id="message"><strong>Sorry !</strong> No Account Found : <a
                                            href='login.php'>Signup here</a></p>
                            </div>
                        </div>
                        <?php
                    }
                }
                ?>
            </div>
        </div>
    </div>
</section>

<?php
require_once "front_common/footer.php";
?>
<!-- // End Footer  -->

