include('cfg/authentication.php'); include('cfg/regdata.php'); db_connect($dbhost, $dbuser, $dbpass); // if login was requested if($_GET['a'] == 'login') { $data = $_POST; if(!isset($data['email']) OR !isset($data['password'])) { header('Location: register.php?am=3'); } if(login($data)) { // then logged-in header('Location: register.php'); } else { header('Location: register.php?am=1'); } exit(); } // end if login requested if($_GET['a'] == 'logout') { if(logout()) { // then logged-out header('Location: register.php?am=0'); } else { header('Location: register.php?am=2'); } exit(); } // end if logout requested // if registration was requested elseif($_GET['a'] == 'register') { $page = 'regform'; if(!$data = $_POST) { $message = 'Error: no data were submitted.'; } // process and register the data $status = validate('basicinfo', $data); $data = process($data); // if successfully validated if($status == 1) { // register the user $status = register($data); if($status == 1) { // log the user in with their information $email = $data['email']; $password = $data['password']; $data = array('email' => $email, 'password' => $password); if(login($data)) { header('Location: register.php'); } // end if logged-in else { $message = 'Error: there was a problem logging you in automatically. Please try to login manually here. If the error persists, please contact bioc [at] indiana (dot) edu.'; } // end if not logged-in } // end if registered else { $message = $status; } // end else for if registered } // end if validated else { echo $status; } // end if error in validating the data } // end if registration else { header('Location: register.php'); } if($message) { echo '