<?php 
include './include/DbHandler.php';
$db = new DbHandler();
$response = array();
$response["error"] = false;
if (isset($_POST['otp']) && $_POST['otp'] != '') {
    $otp = $_POST['otp'];
    $user = $db->activateUser($otp);
    if ($user != NULL) {
        $response["message"] = "User created successfully!";
        $response["profile"] = $user;
    } else {
        $response["message"] = "Sorry! Failed to create your account.";
    }
} else {
    $response["message"] = "Sorry! OTP is missing.";
}
echo json_encode($response);
Example #2
0
            }
        }
    } else {
        $response['error'] = true;
        $response['message'] = 'Activation code is not valid!';
    }
    //output final response
    echo $response;
});
//GET Activate route
$app->get('/activate/:x/:y', function ($x, $y) use($app) {
    //    $email = $app->request->get('x');
    //    $active= $app->request->get('y');
    require_once './classes/DbHandler.php';
    $db = new DbHandler();
    $data = $db->activateUser($x, $y);
    echo "<div class=\"content-main opacity\">\n                    <section class=\"content-section contact-section\">\n                        <div class=\"wrap content-contact\">\n                            <div class=\"container-fluid\">\n                                        <header>\n                                        <h2 class=\"entry-header \">Account Activation</h2>\n                                        </header><hr /><br />\n                                    </div>\n                                        ";
    if ($data['message'] == 'USER_ACTIVE_SUCCESS') {
        echo '<h3>Account Activated</h3>';
    } elseif ($data['message'] == 'USER_ACTIVE_FAIL') {
        echo '<h3>Activation Error</h3>';
    } elseif ($data['message'] == 'USER_NOT_EXIST') {
        echo "<h3>User doesn't exist</h3>";
    }
    echo "</div></section></div>";
});
//GET login route
$app->get('/login', function () use($app) {
    $app->render('login.php');
});
//POST login route