</div> <?php } else { ?> <div class="span-18 comments"> Sorry, the has been an error. </div> <?php } } if ($_REQUEST['method'] == 'login') { try { $user = $services->login($_REQUEST['email'], $_REQUEST['password']); echo $user['username']; } catch (Exception $e) { echo 'invalid'; } die; } if ($_REQUEST['method'] == 'logout') { $services->logout(); echo "ok"; } if ($_REQUEST['method'] == 'register') { $result = $services->registerUser($_REQUEST['username'], $_REQUEST['project'], $_REQUEST['email'], $_REQUEST['password']); echo $result; } ?>
<?php require 'controller.php'; require 'services/SDRServices.php'; $services = new SDRServices(); //data validation $loginerror = false; $user_name = $_POST['username']; $project_name = $_POST['project_name']; $email = $_POST['email']; $password = $_POST['password']; $password_confirm = $_POST['confirmpassword']; try { $logineresult = $services->registerUser($user_name, $project_name, $email, $password); } catch (Exception $e) { $smarty->assign('error', $e->getMessage()); $smarty->display('header.tpl'); $smarty->display('register.tpl'); $smarty->display('footer.tpl'); die; } //set the login params session_start(); $_SESSION['user'] = $logineresult; //everything went fine. We send to the home page header('Location: /');